If the content can be casted to Integer
, you can cast the array to Integer []
and use its elements as int
:
Object [] arr = new Integer[3];
arr[0] = new Integer(1);
arr[1] = new Integer(2);
arr[2] = 3;
Integer [] newa = (Integer []) arr;
for(int i:newa) {
System.err.print(i+" ");
}
Otherwise you can create a new int []
array with the same length as the original and then set the elements in the newly created arrays to the values given by conversion:
int [] arr = new int[origarr.length];
arr[0] = convertTo_int(origarr[0]);
// convertTo_int implementation depends on the type of origarr elements.