import java.util.LinkedList;
public class LinkedListDemo1 {
public static void main(String[] args) {
LinkedList<String> list = new LinkedList<String>();
list.add("apple");
list.add("pear");
list.addFirst("banana");
list.addLast("grape");
list.add(2, "orange");
System.out.println(list);
boolean flag = list.contains("grape");
if (flag) {
System.out.println("grape找到了!");
} else {
System.out.println("grape没找到!");
}
System.out.println("index值为3的数据为:" + list.get(3));
System.out.println("第一个元素为:" + list.getFirst());
System.out.println("最后一个元素为:" + list.getLast());
}
}