Get class name

String getCanonicalName()
Returns the canonical name of the underlying class as defined by the Java Language Specification.
String getName()
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.
String getSimpleName()
Returns the simple name of the underlying class as given in the source code.

public class Main {

  public static void main(String[] args) {
    Class c = new String().getClass();
    String s = c.getName();
    System.out.println(s);
  }
}

The output:


java.lang.String
Home 
  Java Book 
    Reflection  

Class:
  1. Class Reflection
  2. Get Class from class name
  3. Get class name
  4. Get constructors
  5. Get fields in this class
  6. Get Modifiers
  7. Get package
  8. Check class type
  9. Create new instance
  10. Convert class to string