File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes About getClass() method usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "About getClass() method usage" Watch "About getClass() method usage" New topic
Author

About getClass() method usage

Shankara Sharma
Ranch Hand

Joined: Feb 06, 2012
Posts: 41
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: 6109
    
    6

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
Ranch Hand

Joined: Feb 06, 2012
Posts: 41
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: 18117
    
  39

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: 6109
    
    6

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About getClass() method usage
 
Similar Threads
one - one mapping is being enforced with unique="true"
Order a collection by date
Initialization
about variable persistence...
Object is null