aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question? int[] Vs Integer[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question? int[] Vs Integer[]" Watch "Question? int[] Vs Integer[]" New topic
Author

Question? int[] Vs Integer[]

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707


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


cmbhatt
Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42
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

Joined: Feb 28, 2007
Posts: 1707
Thanks Omer,








Regards,
cmbhatt
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question? int[] Vs Integer[]
 
Similar Threads
Generics
What this code does?
pollFirstXxx() question
code output
Collections - Arrays.asList() / List.add()