Here you can find the source of newInstance(Class
public static <T> T newInstance(Class<T> c)
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w . j av a 2 s . c om*/ * Instantiate the class */ public static <T> T newInstance(Class<T> c) { try { return c.newInstance(); } catch (IllegalAccessException e) { throw new RuntimeException("Could not instantiate class " + c.getName(), e); } catch (InstantiationException e) { throw new RuntimeException("Could not instantiate class " + c.getName() + " Does it have a public no-argument constructor?", e); } catch (NullPointerException e) { throw new RuntimeException("Requested class was null", e); } } }