Get Class from class name

static Class<?> forName(String className)
Returns the Class object associated with the class or interface with the given string name.
static Class<?> forName(String name, boolean initialize, ClassLoader loader)
Returns the Class object associated with the class or interface with the given string name, using the given class loader.

Use Class.forName to create Class from a String


public class Main {

  public static void main(String[] args) {

    try {
      Class c = Class.forName("java.lang.String");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
}
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