Create new instance

ReturnMethodSummary
TnewInstance()Creates a new instance of the class represented by this Class object.

public class Main {

  public static void main(String[] args) {

    
    Class c = new String().getClass();
    
    try {
      Object obj = c.newInstance();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
    
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.