aspose file tools*
The moose likes Beginning Java and the fly likes Wrapper class doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wrapper class doubt" Watch "Wrapper class doubt" New topic
Author

Wrapper class doubt

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1050

Integer i=new Integer(100);
System.out.println(i); // why is this line printing 100 and not the reference address


http://www.lifesbizzare.blogspot.com || OCJP:81%
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

Because the Integer class has its toString() method overridden.

And you never see the reference address of objects. What you see when you print an Object instance is its hashCode. It is most likely based on the object address in memory, but it doesn't have to. It most certainly never is the reference address - that's completely hidden. Remember, references aren't pointers like in C.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrapper class doubt
 
Similar Threads
Object References & GC
Is there something wrong ..
== , autoboxing Doubt
cast from string to integer
are these one and the same