java@ LinkedList 学习

package abc.com;

import java.util.LinkedList;

public class TestLinkedList {

    static void prt(Object o) {
System.out.print(o);
}
public static void main(String[] args) {
// TODO Auto-generated method stub LinkedList<Character> books = new LinkedList<Character>(); books.offerFirst('a');
books.offerLast('b');
books.offerLast('c');
books.offerFirst('d'); for(int i=0;i<books.size();++i) {
prt(books.get(i));
}prt("\n"); prt(books.peekFirst() + "\n"); prt(books.peekLast() + "\n"); prt(books); books.pollFirst(); prt(books); prt(books); books.pollLast(); prt(books); } }
运行结果:
dabc
d
c
[d, a, b, c] [a, b, c]
[a, b, c] [a, b]
上一篇:设计模式 - 命令模式(command pattern) 宏命令(macro command) 具体解释


下一篇:Zookeeper--Zookeeper是什么