Java Reflection class invoke default constructor

Description

Java Reflection class invoke default constructor

public class Main {
   public static void main(String args[]) throws Exception {
      Class c = Class.forName("java.lang.String");
      String s = String.class.newInstance(); 
      System.out.println(s.length());
   }//from   w  w w .  j av  a2 s  .  co m
}



PreviousNext

Related