Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Advanced-java] BAsic class question
- From: justin@xxxxxxxxxx (Justin Couch)
- Subject: [Advanced-java] BAsic class question
- Date: Wed, 27 Feb 2002 19:34:47 +1100
dovle wrote: > Suppose I have a class X and I obtain the > Class xClass = X.class ; > > Later, I want to check if an object is instance(exactly) of this class. > > what is the best way to do this ? > > obj.getClass() == xClass ; > > It works always ? ( aka : there is only one Class object instantiated for a > class). Nope. Best bet is to look at the reflection stuff. You'll want the isInstance() method in Class. -- Justin Couch http://www.vlc.com.au/~justin/ Java Architect & Bit Twiddler http://www.yumetech.com/ Author, Java 3D FAQ Maintainer http://www.j3d.org/ ------------------------------------------------------------------- "Humanism is dead. Animals think, feel; so do machines now. Neither man nor woman is the measure of all things. Every organism processes data according to its domain, its environment; you, with all your brains, would be useless in a mouse's universe..." - Greg Bear, Slant -------------------------------------------------------------------
- Follow-Ups:
- [Advanced-java] BAsic class question
- From: Sybille Breunig
- [Advanced-java] BAsic class question
- References:
- [Advanced-java] BAsic class question
- From: dovle
- [Advanced-java] BAsic class question
- Prev by Date: [Advanced-java] BAsic class question
- Next by Date: [Advanced-java] BAsic class question
- Previous by thread: [Advanced-java] BAsic class question
- Next by thread: [Advanced-java] BAsic class question
- Index(es):