import java.util.Iterator;
import java.util.LinkedList;
public class demo1 {
public static void main(String[] args) {
fun3();
}
public static void fun3(){
LinkedList<String> link = new LinkedList<String>();
link.add("每当我听到雨声");
link.add("就像听到了心中的迷茫");
link.removeFirst();
System.out.println(link);
}
//在Java中,可以用isEmpty();判断一个顺序容器ArrayList里面是否有元素,如果有的话返回一个Boolean类型的值false,否则返回true。
public static void fun2(){
LinkedList<String> link = new LinkedList<String>();
link.add("杜甫");
link.add("杜甫1");
link.add("杜甫2");
link.add("杜甫3");
String fir = link.getFirst();
System.out.println(link);
if (!link.isEmpty()) {
String first = link.getFirst();
System.out.println(first);
}
}
public static void fun1(){
LinkedList<String> link = new LinkedList<String>();
link.add("张无忌");
link.add("张无忌1");
link.add("张无忌2");
link.add("张无忌3");
link.addFirst("郭靖");
link.addFirst("郭靖1");
link.addFirst("郭靖2");
Iterator<String> it =link.iterator();
while (it.hasNext()) {
String e =it.next();
System.out.println(e);
}
}
}