Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About getClass() method usage

 
Shankara Sharma
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21117
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic