请帮助我使用以下代码,即使更改值后我也会得到相同的输出
import java.util.*;
class Test {
public static void main(String[] args) {
ArrayList<Integer> a = new ArrayList<Integer>();
// added 0-9 to ArrayList
for(int i=0;i<9;i++)
a.add(new Integer(i));
// initialize the Iterator
Iterator<Integer> i = a.iterator();
// changed the value of first element in List
if(i.hasNext()) {
Integer x = i.next();
x = Integer.valueOf(9);
}
// initialized the iterator again and print all the elements
i = a.iterator();
while(i.hasNext())
System.out.print(i.next());
}
}
//Output : 012345678
值 9 未更新。