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());

   }
}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable