Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Advanced-java] Basic class question
- From: vladimir@xxxxxxx (Vladimir G Ivanovic)
- Subject: [Advanced-java] Basic class question
- Date: Wed, 27 Feb 2002 14:15:15 -0800
"JC" == Justin Couch <justin@xxxxxxxxxx> writes: JC> The obj he was using was of type java.lang.Class and then trying to JC> compare it with instanceof. Actually, I don't think this is the case. "xClass" was the class object in his message, not not "obj". "obj" was some random object, an object he wanted to test for class membership. So Sybille Breunig's proposed > if (obj instanceof X) > // do anything should work just fine. --- Vladimir -------- Vladimir G. Ivanovic http://leonora.org/~vladimir 2770 Cowper St. vladimir@xxxxxxx Palo Alto, CA 94306-2447 +1 650 678 8014 That will aways evaluate to false in the JC> example code he gave. When all you have is a j.l.Class instance to check JC> with, the only thing you can do is use the isInstance() method. If you JC> read the docs, it says that this method is the reflection equivalent of JC> the instanceof operator. Same effect, but the starting point is different.
- References:
- [Advanced-java] Basic class question
- From: Justin Couch
- [Advanced-java] Basic class question
- Prev by Date: [Advanced-java] Of jarfiles and manifests
- Next by Date: [Advanced-java] Japanese Characters
- Previous by thread: [Advanced-java] Basic class question
- Next by thread: [Advanced-java] Using Java to write to Windows Event Log
- Index(es):