Get the class from .class in Java

Description

The following code shows how to get the class from .class.

Example


/* w  w w .  jav  a  2  s  .  co m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    Object object = new String();

    Class cls = java.lang.String.class;
    
    System.out.println(cls);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy