In Java, what's the benefit of int constant declared by an object way:
public final static Integer SOME_CONSTANT = Integer.valueOf(99);
public final static int SOME_CONSTANT = 99;
It depends on how you plan to use the constant. If you have an API which requires an
Integer, then using the
int form will have a small performance penalty because of auto-boxing.
If you just need the primitive, the unboxing of
Integer isn't very expensive but easy to avoid.
Also note that
Integer SOME_CONSTANT = Integer.valueOf(99);
is exactly the same as
Integer SOME_CONSTANT = 99;
*.valueOf() methods were added the API to give the compiler a common way to auto-box primitives.