java - Object type reference variable assigned to a primitive -
in java, int
primitive type , integer
object.
integer x = 4;
this line of code produces no errors, though think technically should if there no special case it. it's object type reference variable being assigned primitive type, not make sense. why not produce error?
this called auto-boxing.
the compiler automatically box primitives when used objects.
Comments
Post a Comment