There is actually some difference between the 2. Looking at the byte code will reveal that info.
public final static int SOME_CONSTANT = 99;
Will be a compile time constant. So the value of this thing will be available as part of the byte code itself.
Byte code :
public static final int SOME_CONSTANT;
descriptor: I
flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
ConstantValue: int 99
public final static Integer SOME_CONSTANT1 = Integer.valueOf(99);
Although instances of Integer
class are immutable, they will not turn into compile time constants. They are run as part of the static initializer of the class.
Byte code :
public static final java.lang.Integer SOME_CONSTANT1;
descriptor: Ljava/lang/Integer;
flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
static {};
descriptor: ()V
flags: ACC_STATIC
Code:
stack=1, locals=0, args_size=0
0: bipush 99
2: invokestatic #14 // Method java/lang/Integer.valueO
f:(I)Ljava/lang/Integer;
5: putstatic #20 // Field SOME_CONSTANT1:Ljava/lang
/Integer;
8: return
LineNumberTable:
line 4: 0
line 5: 8
LocalVariableTable:
Start Length Slot Name Signature