java - When should I pass a class as an argument? -


i confused undrestand when should pass class argument instead of instance. example:

mymethod(classa.class); 

could make example of when , how should pass class argument?

a classic example when creating instance of class through reflection:

//avoiding exception handling, leave static <t> t make(class<t> clazz) {     return clazz.newinstance(); } //... a = make(a.class); 

also, when want make sure @ compile time references belong specific class, used in collections#checkedxxx.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -