Get class name for various object in Java

Description

The following code shows how to get class name for various object.

Example


/*from www  . j  ava  2 s . co m*/
public class Main {

    public static void main(String[] args) {
        System.out.println(Main.class.getName());
        System.out.println(int[].class.getName()); 
        System.out.println(Main[].class.getName());  
    }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy