题目内容:
阅读下列程序
publicclassExample{
publicstaticvoidmain(String[]args){
ArrayListlist=newArrayList();//创建ArrayList集合
list.add("Tom"); //向该集合中添加字符串
list.add("Jerry");
list.add("Donald");
for(ListIteratorit=list.listIterator();it.hasNext();){
Objectobject=it.next();
if("Jerry".equals(object)){
it.set("Speike");
}
}
System.out.println(list);
}
}
程序的运行结果是()
A.[Tom,Speike,Donald]
B.[Tom,Jerry,Speike,Donald]
C.[Tom,Donald]
D.[Tom,Jerry,Donald]
参考答案: