Get the class name of a primitive type in Java

Description

The following code shows how to get the class name of a primitive type.

Example


/*w w  w  . j a v  a  2 s.  c om*/
public class Main {
  public static void main(String[] argv) throws Exception {

    String name = int.class.getName(); // int
    System.out.println(name);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy