Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes what if i print an object without specifing its felds to be printed????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what if i print an object without specifing its felds to be printed?????" Watch "what if i print an object without specifing its felds to be printed?????" New topic
Author

what if i print an object without specifing its felds to be printed?????

Deepakk Verma
Ranch Hand

Joined: Sep 09, 2009
Posts: 31
if i write this code


it is giving me result as

myboxBox@19821f


can you tell me why?
(i know this code is of no use but i was curious to know why is it generating this output)

please explain....
Rahul P Kumar
Ranch Hand

Joined: Sep 26, 2009
Posts: 188
Follow this link. If you want meaningful print, you need to override toString() of Object (object with capital O) class.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what if i print an object without specifing its felds to be printed?????