Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Advanced-java] BAsic class question


  • From: dovle@xxxxxxxxxx (dovle)
  • Subject: [Advanced-java] BAsic class question
  • Date: Wed, 27 Feb 2002 10:26:17 +0200

Hi all , 

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). 

When the Class object loads into memory ? Is it present all the time inthere 
(while the programm executes) ?

What approach is more efficient: keep the Class object or keep the className 
? I was wondering witch equals operation is faster : Class or String ? (I 
suppose class , but I need someone to tell me that this is right or not) .

Hope I don't annoy any of you with those silly questions. I suppose that I 
have the answer for all of those but I want to be shure. 

Thanks again 
dovle