Here you can find the source of newInstanceOf(Class
@SuppressWarnings("unchecked") public static <T extends Object> T newInstanceOf(Class<T> clazz)
//package com.java2s; //License from project: Apache License public class Main { @SuppressWarnings("unchecked") public static <T extends Object> T newInstanceOf(Class<T> clazz) { try {/* w w w . jav a 2 s . com*/ if (clazz.equals(byte[].class)) { return (T) new byte[] {}; } return clazz.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } }