public Object removeFirst()
public Object removeLast()
import java.util.LinkedList;
public class MainClass {
public static void main(String[] a) {
LinkedList list = new LinkedList();
list.add("A");
list.add("B");
list.add("C");
list.add("D");
list.addFirst("X");
list.addLast("Z");
System.out.println(list);
System.out.println(list.getFirst());
System.out.println(list.getLast());
list.removeFirst();
list.removeLast();
System.out.println(list);
}
}
[X, A, B, C, D, Z]
X
Z
[A, B, C, D]