• Post Reply Bookmark Topic Watch Topic
  • New Topic

instanceOf (Sybex)  RSS feed

 
Rami Najjar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you please guys i need help in something it's maybe seems simple but i can't catch how i'ts work in this particular example,
in OCP book in chapter 1 page 8 there are example in how instanceof work with interface





what i can't understand how the last line MotherHippo class effect instanceof statement ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37469
539
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rami Najjar wrote:what i can't understand how the last line MotherHippo class effect instanceof statement ?

For those without the book, note that MotherHippo isn't in the same code block as the other code you posted. It is after a sentence explaining why instanceof Mother compiles. Java doesn't know what classes may implement other interfaces so the code has to compile. And then MotherHippo is the example showing an example where hippo instanceof Mother would be true.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!