| Author |
Difference between instanceof and instanceOf
|
Najmunnisa Sageer
Greenhorn
Joined: May 18, 2008
Posts: 9
|
|
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
Joined: May 28, 2008
Posts: 36
|
|
|
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.
|
Cheers,
Meena
OCPJP 6
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2551
|
|
and other one instanceOf ??
And where did you find the other one ?
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Sunil Belurgikar
Greenhorn
Joined: May 21, 2008
Posts: 14
|
|
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..
|
SCJP 1.6
|
 |
Raphael Rabadan
Ranch Hand
Joined: Jul 05, 2008
Posts: 141
|
|
|
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.
|
SCJP Java 6 (98%) - Story, SCJA (88%) - Story
|
 |
Najmunnisa Sageer
Greenhorn
Joined: May 18, 2008
Posts: 9
|
|
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
Joined: Apr 18, 2008
Posts: 20
|
|
|
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
The question is actually about the difference between instanceof and instanceOf and not instanceof and .class/.getClass()...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: Difference between instanceof and instanceOf
|
|
|