Forums Register Login

instanceof operator

+Pie Number of slices to send: Send
There must be a reference type after the instanceof operator.
By 'reference type', you mean something like Object, and not the variable representing an Object...?
+Pie Number of slices to send: Send
You need to name the Class or Interface that you are asking if the object is an instance of it.
if (myObj instanceof String){
//do something Stringlike
}
+Pie Number of slices to send: Send
reference instanceof ReferenceType
ReferenceType can also be an array reference type, e.g.
ref instanceof int[] // true if ref is an int[]
ReferenceType cannot be java.lang.Class (compile time error) except when reference is declared as an Object.


------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 506 times.
Similar Threads
Wrapping from Integer to int possible?
Test Question - Explanation?
Instance Of operator
instanceof operator
Difference between instanceof and instanceOf
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:26:53.