File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question? int[] Vs Integer[]

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Output:
[12, 2, 43, 67, 4, 1, 23]
[I@5224ee


Output varies:
Isn't its answer that Integer class overrides the toString() method and in case of int[], Object class version of toString() used?

How all the values of Integer[] printed when we merely pass an reference variable. What happens inside the toString(), does it do complete traversal or use Iterator or something.

Please help!!!



cmbhatt
 
Omer Haderi
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the second case you prints the array not the list, so you will get the hashCode of the Object.

here is the toString mystification !
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Omer,








Regards,
cmbhatt
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic