Here you can find the source of newInstance(String className)
public static <T> T newInstance(String className)
//package com.java2s; //License from project: Apache License public class Main { public static <T> T newInstance(String className) { Class<T> clazz = forName(className); return newInstance(clazz); }//from w w w. j av a2s.c om public static <T> T newInstance(Class<T> clazz) { try { return clazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException(clazz.toString(), e); } catch (IllegalAccessException e) { throw new RuntimeException(clazz.toString(), e); } } @SuppressWarnings("unchecked") public static <T> Class<T> forName(String className) { try { return (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException(className, e); } } @SuppressWarnings("unchecked") public static <T> Class<T> forName(String className, boolean initialize, ClassLoader loader) { try { return (Class<T>) Class.forName(className, initialize, loader); } catch (ClassNotFoundException e) { throw new RuntimeException(className, e); } } }