Java Object.getClass()
Syntax
Object.getClass() has the following syntax.
public final Class <?> getClass()
Example
In the following code shows how to use Object.getClass() method.
// ww w.j a v a 2 s. c om
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] args) {
// create a new Main object
GregorianCalendar cal = new GregorianCalendar();
// print the class of cal
System.out.println(cal.getClass());
}
}