是否有任何理由使用 Integer.valueOf(X) 来初始化最终 Integer,如下所示:
public class MyClass
{
public static final Integer DAY_1 = Integer.valueOf(1); // Why do it this way?
public static final Integer DAY_2 = 2; // When it can be done this way?
}
我知道在添加自动装箱之前,这在旧版本的 Java 中是必要的。这种类型的代码还有什么原因吗?或者这只是一个坏习惯?