ArrayList是一个集合,底层维护的是数组结构
数组结构,查询比较快,增删慢
LinkedList是一个集合,底层维护的是链表结构
链表结构,查询比较慢,增删快
TIPS:两者指的都是数据量比较大的情况,而且链表首位操作还是比较快的,中间慢
System.out.println(list2.peek());//获取但不移除集合中的首元素 System.out.println(list2.peekFirst());//获取但不移除集合中的首元素 System.out.println(list2.peekLast());//获取但不移除集合中的尾元素 System.out.println(list2); System.out.println(list2.offer("雪中悍刀行"));//将指定元素添加到集合末尾 System.out.println(list2.offerFirst("吞噬星空"));//将指定元素添加到集合开头 System.out.println(list2.offerLast("完美世界"));//将指定元素添加到集合末尾 System.out.println(list2); /*移除系列*/ System.out.println(list2.poll());//获取并且移除集合中的首元素 System.out.println(list2.pollFirst());//获取并且移除集合中的首元素 System.out.println(list2.pollLast());//获取并且移除集合中的尾元素 System.out.println(list2); System.out.println(list2.element());//获取但不移除集合中的首元素