为啥没全取出来
import java.util.*;
public class LinkedListDemo {
public static void main(String[] args) {
LinkedList<String> link =new LinkedList<String>();
link.add("A");
link.add("B");
link.add("C");
link.add("D");
System.out.println(link.size());
for(int i=0;i<link.size();i++)
{
System.out.println(link.poll());
}
System.out.println(link);
}
}
------解决方案--------------------
你把“System.out.println(link.poll());”替换成“ System.out.println(link.poll() + " size: " + link.size() + " i:" + i);”看看就明白了。。