• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Something intersting about arrays..!!

 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

While i was playing with some codes today..I found something very interesting:


When I run this code, My expectation was:
1)Some memory reference
2)Some memory reference
3)Some memory reference
4)Some memory reference

But i got following as the output:
 
Nadeem Khan
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
st's ouput is as expected but rest is something new to me
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the output i got of following:

System.out.println(ch);

as ch is referring to an Object(array Object) so it must refer to some memory references..as everything else is displaying..!!
 
Nadeem Khan
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
best way to clear such things is to refer API and see the implementation of println() method..hardwork in other words
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic