File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question? int[] Vs Integer[]" Watch "Question? int[] Vs Integer[]" New topic

Question? int[] Vs Integer[]

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710

[12, 2, 43, 67, 4, 1, 23]

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!!!


Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42

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: 1710
Thanks Omer,

I agree. Here's the link:
subject: Question? int[] Vs Integer[]
It's not a secret anymore!