You have to deal with the auto-boxing of java.
Let's take the code
public class test
{
public static void main(String [ ] args)
{
int i = 3;
Object o = i;
return;
}
}
You get the class test.class and
javap -c test let's you inspect the generated bytecode.
Compiled from "test.java"
public class test extends java.lang.Object{
public test();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."":()V
4: return
public static void main(java.lang.String[]);
Code:
0: iconst_3
1: istore_1
2: iload_1
3: invokestatic #2; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
6: astore_2
7: return
}
As you can see the java compiler added
invokestatic #2; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
to create a new Integer from your int and then stores
that new Object in o via astore_2