Class java.lang.Class


  • Class allows to control, load and test other classes or to instantiate objects of any class during runtime.
  • Very powerful (for experts!)
  • Use for debugging output:
    System.out.println("In "+
    	this.getClass().getName());
    	
  • Can be used for dynamic object generation while running.
    String classname = "myclass";
    Object new_object = Class.forName(classname).newInstance();
    	

Java Tutorial - Standard Classes Jens Trapp, 1997