Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals and this

 
srinivas sridaragaddi
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


output: objects are different

where as i was expecting objects are same can anyone explain me
as to why it is generating this output?
 
Gautam Pandey
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic