Get the fully-qualified name of a class in Java

Description

The following code shows how to get the fully-qualified name of a class.

Example


/*www  .ja  v a2s.  com*/
public class Main {
  public static void main(String[] argv) throws Exception {

    Class cls = java.lang.String.class;
    String name = cls.getName(); 
    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