我用Netbeans IDE 8.0.2 写java,部分程序如下:
ArrayList List = new ArrayList();
while(true){
if(input.nextInt() == 0) break;
List.add(input);
i++;
System.out.println("You have input "+ i + " numbers");
}
int[] num = new int[List.size()];
请问如何把List里面的元素放到新定义的num数组中?
如果输出的全是整型的话可以使用下面这种方式
ArrayList<Integer> List = new ArrayList<Integer>();如果输出的不确定那就得循环List一个一个给数组赋值了