wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inquisition Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inquisition Question" Watch "Inquisition Question" New topic
Author

Inquisition Question

Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97


why the above code prints false???
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Because int[] does not override the equals method.

By default equals method returns true if both the reference are pointing to the same object whcih is not in your case.

To compare arrays use Arrays.equals(arr,arr) method.


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
Thanks Siva.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inquisition Question
 
Similar Threads
Array Help
Doubt in Array Declaration
Array/Constructor Problem
arrays equals() confusion
equals() doubt