Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance

 
archu sweet
Ranch Hand
Posts: 66
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I want to know how come p0=p1 is true ??
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you mean p0 == p1, because p0 = p1 is not a boolean expression.

Why do you think it is true? Did you try this code out?
 
archu sweet
Ranch Hand
Posts: 66
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i meant p0 == p1...i tried out it says it is valid....but they belong to different classes how can they be equal ??
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's valid to compare them, because a ClassB IS-A ClassA. Which means that it's possible for ClassA and ClassB references to be equal. For example:

Then p0 == p1 is true.

The compiler will only stop you comparing them if they can't possibly be equal.
 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p0 and p1 are not equal, what makes you think they are?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic