Type Parameters:
E - the type of elements held in this collection
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, SequencedCollection<E>

  • Field Summary

  • Constructor Summary

    Constructors

    Constructs an empty list.

    Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.

  • Method Summary

    void

    add(int index, E element)

    Inserts the specified element at the specified position in this list.

    boolean

    add(E e)

    Appends the specified element to the end of this list.

    boolean

    Inserts all of the elements in the specified collection into this list, starting at the specified position.

    boolean

    Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.

    void

    addFirst(E e)

    Inserts the specified element at the beginning of this list.

    void

    addLast(E e)

    Appends the specified element to the end of this list.

    void

    clear()

    Removes all of the elements from this list.

    clone()

    Returns a shallow copy of this LinkedList.

    boolean

    Returns true if this list contains the specified element.

    Returns an iterator over the elements in this deque in reverse sequential order.

    element()

    Retrieves, but does not remove, the head (first element) of this list.

    get(int index)

    Returns the element at the specified position in this list.

    getFirst()

    Returns the first element in this list.

    getLast()

    Returns the last element in this list.

    int

    Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

    int

    Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

    listIterator(int index)

    Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list.

    boolean

    offer(E e)

    Adds the specified element as the tail (last element) of this list.

    boolean

    offerFirst(E e)

    Inserts the specified element at the front of this list.

    boolean

    offerLast(E e)

    Inserts the specified element at the end of this list.

    peek()

    Retrieves, but does not remove, the head (first element) of this list.

    peekFirst()

    Retrieves, but does not remove, the first element of this list, or returns null if this list is empty.

    peekLast()

    Retrieves, but does not remove, the last element of this list, or returns null if this list is empty.

    poll()

    Retrieves and removes the head (first element) of this list.

    pollFirst()

    Retrieves and removes the first element of this list, or returns null if this list is empty.

    pollLast()

    Retrieves and removes the last element of this list, or returns null if this list is empty.

    pop()

    Pops an element from the stack represented by this list.

    void

    push(E e)

    Pushes an element onto the stack represented by this list.

    remove()

    Retrieves and removes the head (first element) of this list.

    remove(int index)

    Removes the element at the specified position in this list.

    boolean

    Removes the first occurrence of the specified element from this list, if it is present.

    Removes and returns the first element from this list.

    boolean

    Removes the first occurrence of the specified element in this list (when traversing the list from head to tail).

    Removes and returns the last element from this list.

    boolean

    Removes the last occurrence of the specified element in this list (when traversing the list from head to tail).

    reversed()

    Returns a reverse-ordered view of this collection.

    set(int index, E element)

    Replaces the element at the specified position in this list with the specified element.

    int

    size()

    Returns the number of elements in this list.

    toArray()

    Returns an array containing all of the elements in this list in proper sequence (from first to last element).

    <T> T[]

    toArray(T[] a)

    Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

  • Constructor Details

    • LinkedList

    • LinkedList

  • Method Details

    • getFirst

    • getLast

    • removeFirst

    • removeLast

    • addFirst

    • addLast

    • contains

    • size

    • add

    • remove

    • addAll

    • addAll

    • clear

    • get

    • set

    • add

    • remove

    • indexOf

    • lastIndexOf

    • peek

    • element

    • poll

    • remove

    • offer

    • offerFirst

    • offerLast

    • peekFirst

    • peekLast

    • pollFirst

    • pollLast

    • push

    • pop

    • removeFirstOccurrence

    • removeLastOccurrence

    • listIterator

    • descendingIterator

    • clone

    • toArray

    • toArray

    • spliterator

    • reversed