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 Inquisition Question 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 "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.
 
Consider Paul's rocket mass heater.
 
subject: Inquisition Question
 
Similar Threads
Array Help
Doubt in Array Declaration
Array/Constructor Problem
arrays equals() confusion
equals() doubt