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 equals and this 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 "equals and this" Watch "equals and this" New topic
Author

equals and this

srinivas sridaragaddi
Ranch Hand

Joined: Jul 24, 2007
Posts: 225


output: objects are different

where as i was expecting objects are same can anyone explain me
as to why it is generating this output?


SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
Gautam Pandey
Greenhorn

Joined: Sep 21, 2007
Posts: 21
since equals method is not overidden in MyClass , it uses the Object's equals version which returns true on if the objects are referring to the same object. Since in your case its creating two different objects , it returns false.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: equals and this
 
Similar Threads
equivalence
equals method
Equals
doubt in mock exam java belt
Hi