- import java.util.ArrayList;
- import java.util.ListIterator;
- public class TestListIterator {
- public static void main(String[] args) {
- ArrayList al = new ArrayList();
- al.add("abc");
- al.add("aa");
- al.add("abc");
- for(ListIterator ll = al.listIterator(); ll.hasNext();)
- {
- String s = (String)ll.next();
- if(s.equals("abc"))
- ll.set("hahaha");
- }
- System.out.println(al);
- }
- }
复制代码
也没错啊 |