import java.util.*; public class test { public static void main(String args[]) { ArrayList tmpList = new ArrayList(); tmpList.add(new Integer(1)); tmpList.add(new Integer(2)); tmpList.add(new Integer(3)); Integer tmpInteger[] = new Integer[tmpList.size()]; int tmpInt[] = new int[tmpList.size()]; tmpList.toArray(tmpInteger); for(int i = 0; i < tmpInteger.length;i++) { tmpInt[i] = tmpInteger[i].intValue(); System.out.println(tmpInt[i]); } } }
int[] ret = new int[arrayList.size()];
int i=0;
while(iterator.hasNext()){
ret[i++] = Integer.parseInt((String)iterator.next());
}呵呵,没有测试过
呵呵.java基础问题,楼上的都要看书
bookhome(bookhome) 我试过,你的这种方法可以的,不过要改一下
int ret[]=new int[arrayList.size()];
for(int i=0;i<arrayList.size();i++)
{
ret[i]=((Integer)arrayList.get(i)).intValue();
}
其实转过来,没有什么意义!
public class test {
public static void main(String args[]) {
ArrayList tmpList = new ArrayList();
tmpList.add(new Integer(1));
tmpList.add(new Integer(2));
tmpList.add(new Integer(3));
Integer tmpInteger[] = new Integer[tmpList.size()];
int tmpInt[] = new int[tmpList.size()];
tmpList.toArray(tmpInteger);
for(int i = 0; i < tmpInteger.length;i++) {
tmpInt[i] = tmpInteger[i].intValue();
System.out.println(tmpInt[i]);
}
}
}