Here you can find the source of newArrayOfType(int typeCode, int size)
private static Object newArrayOfType(int typeCode, int size)
//package com.java2s; //License from project: Open Source License import java.sql.Types; public class Main { /**/*from w w w . j a v a2s.c o m*/ * Create a new array of the specified type and size. */ private static Object newArrayOfType(int typeCode, int size) { return newArrayOfType(typeCode, size, null); } /** * Create a new array of the specified size, initialize by copying values * from the specified array. Note that the length of curArray must be less * than or equal to "size". */ private static Object newArrayOfType(int typeCode, int size, Object curArray) { Object result = null; switch (typeCode) { case Types.DOUBLE: { double[] newArray = new double[size]; if (curArray != null) { double[] oldArray = (double[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } break; /* case Types.FLOAT: { float[] newArray = new float[size]; if (curArray != null) { float[] oldArray = (float[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } break; */ case Types.INTEGER: { /* if (is64Bit()) { long[] newArray = new long[size]; if (curArray != null) { long[] oldArray = (long[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } else { int[] newArray = new int[size]; if (curArray != null) { int[] oldArray = (int[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } */ int[] newArray = new int[size]; if (curArray != null) { int[] oldArray = (int[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } break; case Types.BIT: { boolean[] newArray = new boolean[size]; if (curArray != null) { boolean[] oldArray = (boolean[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } break; default: { String[] newArray = new String[size]; if (curArray != null) { String[] oldArray = (String[]) curArray; for (int i = 0; i < Math.min(oldArray.length, size); i++) { newArray[i] = oldArray[i]; } } result = newArray; } break; } return result; } }