package com.yjf.esupplier.common.test; import java.util.LinkedList; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/12 15:24 */ public class LinkedListDemo { /** * LinkedList * 底层数据结构是链表,查询慢,增删快线程不安全,效率高 * LinkedList 类特有功能 * public void addFirst(E e) 及 addLast(E e) * public E getFirst()及getLast() * public E removeFirst()及public E removeLast() */ public static void main(String[] args) { // 创建集合对象 LinkedList link = new LinkedList(); // 添加元素 link.add("hello"); link.add("world"); link.add("java"); // 输出对象名 System.out.println("link:" + link); // public void addFirst(Object e) link.addFirst("javaee"); // public void addLast(Object e) link.addLast("android"); // 输出对象名 System.out.println("link:" + link); // public Object getFirst() System.out.println("getFirst:" + link.getFirst()); // public Obejct getLast() System.out.println("getLast:" + link.getLast()); // public Object removeFirst() System.out.println("removeFirst:" + link.removeFirst()); // public Object removeLast() System.out.println("removeLast:" + link.removeLast()); // 输出对象名 System.out.println("link:" + link); } }