import java.util.Iterator;
import java.util.LinkedList;
public class LinkedListDemo {
public static void main(String[] args) {
LinkedList<String> link = new LinkedList<String>();
link.add("wo");
link.add("ai");
link.add("xue");
link.add("xi");
//linkedList 特有的功能
link.addFirst("hello");
link.addLast("bye");
System.out.println(link);
System.out.println("----------------");
System.out.println("removeLast" + link.removeLast());
System.out.println("----------------");
System.out.println("getFirst"+link.getFirst());
System.out.println("----------------");
Iterator<String> iterator = link.iterator();
while (iterator.hasNext()) {
String string = iterator.next();
System.out.println(string);
}
}
}
LinkedList的特有功能
最新推荐文章于 2020-08-14 21:29:45 发布