This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why a primitive variable can point to wrapper object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why a primitive variable can point to wrapper object?" Watch "Why a primitive variable can point to wrapper object?" New topic
Author

Why a primitive variable can point to wrapper object?

Mark Moge
Ranch Hand

Joined: Mar 14, 2009
Posts: 100

Can someone explain me why the primitive variable can point to wrapper object?
for example:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Moge
Ranch Hand

Joined: Mar 14, 2009
Posts: 100

Autoboxing and wrapper classe was added to Java 1.5. So now I can see how it works Thanks for replay.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Why a primitive variable can point to wrapper object?
 
It's not a secret anymore!