This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
 
subject: Question? int[] Vs Integer[]
 
Similar Threads
pollFirstXxx() question
code output
What this code does?
Collections - Arrays.asList() / List.add()
Generics