public static < T > T newInstance ( Class < T > cl ) { try { return cl . getDeclaredConstructor ( ) . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e ) { throw new RuntimeException ( e ) ; } }
Create a new instance of a class