- import java.util.Iterator;
- import java.util.LinkedList;
- import java.util.ListIterator;
- public class LinkedListDemo {
- public static void main(String[] args) {
- LinkedList li = new LinkedList();
- li.add(new Person("wangwu0", 25));
- li.add(new Person("wangwu32", 65));
- li.add(new Person("wangwu4", 34));
- li.add(new Person("wangwu3", 25));
- li.add(new Person("wangwu3", 25));
- Iterator it = li.iterator();
- ListIterator lis=li.listIterator();
- while (it.hasNext())
- System.out.println(it.next());
- System.out.println() ;
- System.out.println(li.remove(2));
- while (lis.hasNext())
- System.out.println(lis.next());
- }
复制代码
为什么会报出这个异常?
|
|