| Author |
About getClass() method usage
|
Shankara Sharma
Greenhorn
Joined: Feb 06, 2012
Posts: 14
|
|
What does the below statements mean?
ClassA classA=new ClassA();
classA.getClass(); -> What this statement will do at runtime?
Will it return the name of the class?
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3144
|
|
Shankara Sharma wrote:
classA.getClass(); -> What this statement will do at runtime?
Will it return the name of the class?
You'll want to become acquainted with the API docs: http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#getClass()
|
 |
Shankara Sharma
Greenhorn
Joined: Feb 06, 2012
Posts: 14
|
|
public final Class<?> getClass()
Returns the runtime class of this Object. The returned Class object is the object that is locked by static synchronized methods of the represented class.
What does Class Object and Class<?> mean?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 14613
|
|
Shankara Sharma wrote:What does Class Object and Class<?> mean?
A Class object is an instance of the Class class. And the Class class supports generics -- so <?> is just a wildcard if you are not specific on which class you want access to.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3144
|
|
Shankara Sharma wrote:p
What does Class Object
http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html
and Class<?> mean?
java generics tutorial
|
 |
 |
|
|
subject: About getClass() method usage
|
|
|