Forums Register Login

Wrapper class doubt

+Pie Number of slices to send: Send
Integer i=new Integer(100);
System.out.println(i); // why is this line printing 100 and not the reference address
+Pie Number of slices to send: Send
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.
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 765 times.
Similar Threads
cast from string to integer
Is there something wrong ..
== , autoboxing Doubt
are these one and the same
Object References & GC
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:15:50.