In java there is a way that makes us enabled to get the object class name at runtime.In java there is a way that makes us enabled to get the object class name at runtime.
java get Object class name
In java there is a way that makes us enabled to get the object class name at runtime. It can be done by calling the getClass() method on the class object. Then by calling the method getName() we can get the name of the object class.
In our example java program we have created a class RoseIndia and we have created an object of this class. Now we will be calling method getClass() on this object to get the class.
roseIndiaObject.getClass() returns the runtime class. roseIndiaObject.getClass().getName() gets the class name of the created object at runtime. Here is the full java code of program which will be getting the object's class name as follows:
Object's Class name =>RoseIndia