Here you can find the source of toArray(int[] intArray)
public static Object[] toArray(int[] intArray)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] toArray(Object[] objArray) { if (objArray == null) return null; int[] intArray = new int[objArray.length]; for (int i = 0; i < objArray.length; i++) if (objArray[i] == null) intArray[i] = 0;//from w ww. j a v a 2 s . c o m else if (objArray[i] instanceof Number) intArray[i] = ((Number) objArray[i]).intValue(); else intArray[i] = parseInt(objArray[i].toString()); return intArray; } public static Object[] toArray(int[] intArray) { if (intArray == null) return null; Integer[] objArray = new Integer[intArray.length]; for (int i = 0; i < intArray.length; i++) objArray[i] = new Integer(intArray[i]); return objArray; } public static int parseInt(String str) { try { if (str == null) return 0; str = str.trim(); if (str.startsWith("+")) str = str.substring(1); int o = str.indexOf('.'); if (o >= 0) str = str.substring(0, o); return Integer.parseInt(str); } catch (NumberFormatException e) { return 0; } } }