Home »
Java programming language
Java Object Class final Class getClass() method with Example
Java Object class final Class getClass() method: Here, we are going to learn about the final Class getClass() method of Object class with its syntax and example.
Submitted by Preeti Jain, on June 28, 2019
Object Class final Class getClass()
- This method is available in java.lang.Object.getClass().
- This method is used to returns the Class class object.
- The returned Class object is the object that is locked by static synchronized methods of the given class.
- This method is final so we can't override it.
Syntax:
final Class getClass(){
}
Parameter(s):
We don't pass any object as a parameter in the method of the Object class.
Return value:
The return type of this method is Class that means this method returns Class object.
Java program to demonstrate example of Object Class getClass() method
import java.lang.Object;
public class ObjectClass {
// Java program to demonstrate working of
// getClass() method of Object class
public static void main(String[] args) {
Float fl = new Float(10.f);
Class cl = fl.getClass();
System.out.println("The name of Class of Float fl is : " +
cl.getName());
}
}
Output
D:\Programs>javac ObjectClass.java
D:\Programs>java ObjectClass
The name of Class of Float fl is : java.lang.Float