• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why a primitive variable can point to wrapper object?

 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain me why the primitive variable can point to wrapper object?
for example:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can't. And in your example, it's not.

Java auto-boxing is extracting the value, 45, and assigning it to the int. There is no reference to the Integer instance.
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Autoboxing and wrapper classe was added to Java 1.5. So now I can see how it works Thanks for replay.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic