Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

meaning - OCA (Sybex)

 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Team

Any one please tell me the simple ,meaning of this  statement;

OCA Book Page 63


a instanceof b True if the reference that a points to is an instance of
a class, subclass, or class that implements a particular
interface, as named in b
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15629
46
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That explains the instanceof operator. There's more about this in Oracle's Java Tutorials, on this page.

You can use instanceof to check if an object is of a specific type. An object is an instance of some type X if the class of the object is X or a subclass of X, or, when X is an interface, if the object's class or one of its superclasses implements interface X.
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use the enter key in the middle of the paragraph; let the users' browsers work out the line lengths for themselves.
OCA Book Page 63 wrote:a instanceof b True if the reference that a points to is an instance of a class, subclass, or class that implements a particular interface, as named in b
Is that all it says about instanceof? Does it say anything about nulls? Have you seen what the Java® Language Specification says about instanceof? It is difficult to read, but look at the last sentence above the blcok with the code in.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Is that all it says about instanceof?

On that page, yes. Because it just gives a high level one sentence on the keyword. The actual explanation of instanceof (which does include nulls) is on page 283
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaaaaaaaaaaaaaaah! Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic