When declaring this in a class:
Integer i = 9;
It complies now due to autoboxing I believe, is i
considered primitive data type?
No, the type of i
is still Integer
(the reference type) - that's how it's declared, after all. The fact that it happens to be initialized using an int
is entirely separate from the type of the variable. The literal 9
is a value of type int
, but it's boxed into an Integer
.
The code is equivalent to:
Integer i = Integer.valueOf(9);
See more on this question at Stackoverflow