耍起来
package com.beyond;
import java.util.*;
public class LinkedListTest {
public static void main(String[] args) {
List<Integer> list = new LinkedList<>();
List<Integer> list1 = new ArrayList<>();
list1.add(1);
list1.add(2);
list1.add(3);
list.add(3);
list.add(9);
System.out.println(list);
list.add(0,4);
System.out.println(list);
list.addAll(list1);
list.addAll(2,list1);
System.out.println(list);
((LinkedList<Integer>) list).addFirst(2);
System.out.println(list);
((LinkedList<Integer>) list).addLast(9);
System.out.println(list);
System.out.println(list.get(3));
Object clone = ((LinkedList<Integer>) list).clone();
System.out.println(clone.toString());
System.out.println(list.contains(2));
System.out.println(((LinkedList<Integer>) list).element());
System.out.println(list.indexOf(2));
System.out.println(list.lastIndexOf(2));
ListIterator<Integer> iterator = list.listIterator();
while (iterator.hasNext()){
System.out.print(iterator.next()+" ");
}
System.out.println();
boolean offer = ((LinkedList<Integer>) list).offer(5);
System.out.println(list);
((LinkedList<Integer>) list).offerLast(0);
System.out.println(list);
System.out.println(((LinkedList<Integer>) list).peek());
System.out.println(((LinkedList<Integer>) list).peekFirst());
System.out.println(((LinkedList<Integer>) list).peekLast());
List<String> list2 = new LinkedList<>();
System.out.println(((LinkedList<Integer>) list).poll());
System.out.println(((LinkedList<Integer>) list).pollFirst());
System.out.println(((LinkedList<Integer>) list).pollLast());
System.out.println(((LinkedList<Integer>) list).pop());
System.out.println(((LinkedList<Integer>) list).pop());
((LinkedList<Integer>) list).push(1001);
System.out.println(list);
list.set(0, 99);
System.out.println(list);
System.out.println(list.size());
Spliterator<Integer> spliterator = list.spliterator();
Spliterator<Integer> split = spliterator.trySplit();
int characteristics = split.characteristics();
System.out.println(characteristics);
}
}