File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question regarding using equals()

 
kay lin
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
For exam Objective 5.2
it says :
the compiler will not allow == if the classes are not in the same hierarchy..

now my question is what does it mean by "classes are not in the same hierarchy"...does it mean classes not in the package or something else??
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it's about inheritance. Parent class and subclass.


You can compare A and B, but you cannot compare String and Integer.
 
Naseem Khan
Ranch Hand
Posts: 809
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
No, it's about inheritance. Parent class and subclass.


You can compare A and B, but you cannot compare String and Integer.


One more thing, this will work...



EDIT: As per your subject line: question regarding using equals(). It looks like you are asking whether equals() will work or not when classes are not in the same hierarchy? Call to inherited equals() will work even if there is not inheritance relationship between the classes as discussed below.

e.g.,



Naseem
[ September 07, 2006: Message edited by: Naseem Khan ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic