Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between instanceof and instanceOf

 
Najmunnisa Sageer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anyone help me to differentiate between instanceof and instanceOf operators.

I know that the instanceof operator is used for checking an object is of particular type and its used for object reference variables only and other one instanceOf ??

Thanks

Neju
 
Meena Ajay
Ranch Hand
Posts: 38
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not read about instanceOf with a capital 'O'.I think we have only one instanceof operator.As you said, the instanceof operator is used to check if an object is an instance of a specific class or interface.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and other one instanceOf ??

And where did you find the other one ?
 
Sunil Belurgikar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instanceOf with capital O can be used as variable name.
Exam creators use this to confuse you.
instanceof is java keyword which checks if perticular object is instance of the type..
 
Raphael Rabadan
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be doing whizlabs exam. It's there where I saw a questions like this. instanceOf isn't a keyword, you can use it as class name, variable name or anything.
 
Najmunnisa Sageer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had a doubt when I was reading our Scjp Faq(under the topic:What are some potential trips/traps in the SCJP exam? )
Now its cleared.

Thanks to all of you.

Neju.
 
Ramakrishna Konanki
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is actually about the difference between instanceof and instanceOf and not instanceof and .class/.getClass()...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic