• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Output of a simple code

 
Douglas Boff Nandi
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why the output of this code finish with 19821f? Thank you for all.
 
armando fonseca
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because it is returning the memory address of the array returned by the method .values().
 
Douglas Boff Nandi
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Now its clear to me
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the output exactly looks something like this

[LEnumTest$Animals;@19821f


And 19821f is not the memory address of the array. It is the value returned by the toString method of Enum[] class. So basically 12821f is the hash code for the enum array...
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the output exactly looks something like this

[LEnumTest$Animals;@19821f


And 19821f is not the memory address of the array. It is the value returned by the toString method of Enum[] class. So basically 12821f is the hash code for the enum array...

[Sorry, I don't know if it is my fault or it happens when you do a quick reply ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic