Here you can find the source of newArray(Object obj, int size)
public static Object newArray(Object obj, int size)
//package com.java2s; //License from project: Open Source License public class Main { public static Object newArray(Object obj, int size) { if (obj.getClass().equals(Integer.class)) { return new int[size]; }/* w w w . j a v a 2 s . c o m*/ if (obj.getClass().getName().contains("I")) { return new int[size]; } if (obj.getClass().getName().contains("F")) { return new float[size]; } if (obj.getClass().getName().contains("C")) { return new char[size]; } if (obj.getClass().getName().contains("J")) { return new long[size]; } if (obj.getClass().getName().contains("S")) { return new short[size]; } if (obj.getClass().getName().contains("B")) { // byte return new byte[size]; } if (obj.getClass().getName().contains("Z")) { // boolean return new boolean[size]; } if (obj.getClass().getName().contains("D")) { return new double[size]; } return null; // UNKNOWN TYPE. } }