Here you can find the source of newInstance(Class> cls)
public static Object newInstance(Class<?> cls)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.InvocationTargetException; public class Main { public static Object newInstance(Class<?> cls) { try {/*from w ww.j a v a2 s .c om*/ return cls.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; } public static Object newInstance(Class<?> cls, Class<?>[] params, Object... args) { try { return cls.getConstructor(params).newInstance(args); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } return null; } }