Possible Duplicate:
convert String arraylist to string array in java?
Following is my code
ArrayList<String> IdList = new ArrayList<String>(); and I want to copy items from IDList to int IdArray[].
Possible Duplicate:
convert String arraylist to string array in java?
Following is my code
ArrayList<String> IdList = new ArrayList<String>(); and I want to copy items from IDList to int IdArray[].
Try this stuff,
int arr[] = new int[arrList.size()]; for (int i = 0; i < arrList.size(); i++) { arr[i] = Integer.parseInt(arrList.get(i)); } I think you must iterate through all items, which are Strings, and parse each of them into an int to populate your new int[] array.
String [] outStrArray = (String [])IdList.toArray()
Collection.toArray() returns a Object[].