# LinkedList

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Fields](https://developer.android.com/reference/java/util/LinkedList#inhfields)\|[Ctors](https://developer.android.com/reference/java/util/LinkedList#pubctors)\|[Methods](https://developer.android.com/reference/java/util/LinkedList#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/LinkedList#inhmethods)  

# LinkedList

`
public


class
LinkedList
`  
`


``


``


``

extends `[AbstractSequentialList](https://developer.android.com/reference/java/util/AbstractSequentialList)`<E>


``


implements

`[Cloneable](https://developer.android.com/reference/java/lang/Cloneable)`,

`[Deque](https://developer.android.com/reference/java/util/Deque)`<E>,

`[List](https://developer.android.com/reference/java/util/List)`<E>,

`[Serializable](https://developer.android.com/reference/java/io/Serializable)`


`

|---|---|---|---|---------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||||
| ↳ | [java.util.AbstractCollection](https://developer.android.com/reference/java/util/AbstractCollection)\<E\> ||||
|   | ↳ | [java.util.AbstractList](https://developer.android.com/reference/java/util/AbstractList)\<E\> |||
|   |   | ↳ | [java.util.AbstractSequentialList](https://developer.android.com/reference/java/util/AbstractSequentialList)\<E\> ||
|   |   |   | ↳ | java.util.LinkedList\<E\> |

<br />

*** ** * ** ***

Doubly-linked list implementation of the`List`and`Deque`interfaces. Implements all optional list operations, and permits all elements (including`null`).

All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.

**Note that this implementation is not synchronized.** If multiple threads access a linked list concurrently, and at least one of the threads modifies the list structurally, it*must* be synchronized externally. (A structural modification is any operation that adds or deletes one or more elements; merely setting the value of an element is not a structural modification.) This is typically accomplished by synchronizing on some object that naturally encapsulates the list. If no such object exists, the list should be "wrapped" using the[Collections.synchronizedList](https://developer.android.com/reference/java/util/Collections#synchronizedList(java.util.List<T>))method. This is best done at creation time, to prevent accidental unsynchronized access to the list:  

```
   List list = Collections.synchronizedList(new LinkedList(...));
```

The iterators returned by this class's`iterator`and`listIterator`methods are*fail-fast* : if the list is structurally modified at any time after the iterator is created, in any way except through the Iterator's own`remove`or`add`methods, the iterator will throw a[ConcurrentModificationException](https://developer.android.com/reference/java/util/ConcurrentModificationException). Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw`ConcurrentModificationException`on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness:*the fail-fast behavior of iterators should be used only to detect bugs.*

This class is a member of the[Java Collections Framework](https://reference/java/util/package-summary.html#CollectionsFramework).  
**See also:**

- [List](https://developer.android.com/reference/java/util/List)
- [ArrayList](https://developer.android.com/reference/java/util/ArrayList)

## Summary

|                                                                                                                                                                                                                  ### Inherited fields                                                                                                                                                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.util.AbstractList](https://developer.android.com/reference/java/util/AbstractList) |------------------|----------------------------------------------------------------------------------------------------------------------------------------------------| | ` protected int` | [modCount](https://developer.android.com/reference/java/util/AbstractList#modCount) The number of times this list has been*structurally modified*. | |

|                                                                                                                                                                        ### Public constructors                                                                                                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[LinkedList](https://developer.android.com/reference/java/util/LinkedList#LinkedList())`() ` Constructs an empty list.                                                                                                                                                                                                                                           |
| ` `[LinkedList](https://developer.android.com/reference/java/util/LinkedList#LinkedList(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. |

|                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                                             | ` `[add](https://developer.android.com/reference/java/util/LinkedList#add(E))`(E e) ` Appends the specified element to the end of this list.                                                                                                                                                                                                                                         |
| ` void`                                                                                | ` `[add](https://developer.android.com/reference/java/util/LinkedList#add(int,%20E))`(int index, E element) ` Inserts the specified element at the specified position in this list.                                                                                                                                                                                                  |
| ` boolean`                                                                             | ` `[addAll](https://developer.android.com/reference/java/util/LinkedList#addAll(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` 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. |
| ` boolean`                                                                             | ` `[addAll](https://developer.android.com/reference/java/util/LinkedList#addAll(int,%20java.util.Collection<?%20extends%20E>))`(int index, `[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Inserts all of the elements in the specified collection into this list, starting at the specified position.                                |
| ` void`                                                                                | ` `[addFirst](https://developer.android.com/reference/java/util/LinkedList#addFirst(E))`(E e) ` Inserts the specified element at the beginning of this list.                                                                                                                                                                                                                         |
| ` void`                                                                                | ` `[addLast](https://developer.android.com/reference/java/util/LinkedList#addLast(E))`(E e) ` Appends the specified element to the end of this list.                                                                                                                                                                                                                                 |
| ` void`                                                                                | ` `[clear](https://developer.android.com/reference/java/util/LinkedList#clear())`() ` Removes all of the elements from this list.                                                                                                                                                                                                                                                    |
| ` `[Object](https://developer.android.com/reference/java/lang/Object)                  | ` `[clone](https://developer.android.com/reference/java/util/LinkedList#clone())`() ` Returns a shallow copy of this`LinkedList`.                                                                                                                                                                                                                                                    |
| ` boolean`                                                                             | ` `[contains](https://developer.android.com/reference/java/util/LinkedList#contains(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns`true`if this list contains the specified element.                                                                                                                                          |
| ` `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`         | ` `[descendingIterator](https://developer.android.com/reference/java/util/LinkedList#descendingIterator())`() ` Returns an iterator over the elements in this deque in reverse sequential order.                                                                                                                                                                                     |
| ` E`                                                                                   | ` `[element](https://developer.android.com/reference/java/util/LinkedList#element())`() ` Retrieves, but does not remove, the head (first element) of this list.                                                                                                                                                                                                                     |
| ` E`                                                                                   | ` `[get](https://developer.android.com/reference/java/util/LinkedList#get(int))`(int index) ` Returns the element at the specified position in this list.                                                                                                                                                                                                                            |
| ` E`                                                                                   | ` `[getFirst](https://developer.android.com/reference/java/util/LinkedList#getFirst())`() ` Returns the first element in this list.                                                                                                                                                                                                                                                  |
| ` E`                                                                                   | ` `[getLast](https://developer.android.com/reference/java/util/LinkedList#getLast())`() ` Returns the last element in this list.                                                                                                                                                                                                                                                     |
| ` int`                                                                                 | ` `[indexOf](https://developer.android.com/reference/java/util/LinkedList#indexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` 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`                                                                                 | ` `[lastIndexOf](https://developer.android.com/reference/java/util/LinkedList#lastIndexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` 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](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/LinkedList#listIterator(int))`(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](https://developer.android.com/reference/java/util/LinkedList#offer(E))`(E e) ` Adds the specified element as the tail (last element) of this list.                                                                                                                                                                                                                        |
| ` boolean`                                                                             | ` `[offerFirst](https://developer.android.com/reference/java/util/LinkedList#offerFirst(E))`(E e) ` Inserts the specified element at the front of this list.                                                                                                                                                                                                                         |
| ` boolean`                                                                             | ` `[offerLast](https://developer.android.com/reference/java/util/LinkedList#offerLast(E))`(E e) ` Inserts the specified element at the end of this list.                                                                                                                                                                                                                             |
| ` E`                                                                                   | ` `[peek](https://developer.android.com/reference/java/util/LinkedList#peek())`() ` Retrieves, but does not remove, the head (first element) of this list.                                                                                                                                                                                                                           |
| ` E`                                                                                   | ` `[peekFirst](https://developer.android.com/reference/java/util/LinkedList#peekFirst())`() ` Retrieves, but does not remove, the first element of this list, or returns`null`if this list is empty.                                                                                                                                                                                 |
| ` E`                                                                                   | ` `[peekLast](https://developer.android.com/reference/java/util/LinkedList#peekLast())`() ` Retrieves, but does not remove, the last element of this list, or returns`null`if this list is empty.                                                                                                                                                                                    |
| ` E`                                                                                   | ` `[poll](https://developer.android.com/reference/java/util/LinkedList#poll())`() ` Retrieves and removes the head (first element) of this list.                                                                                                                                                                                                                                     |
| ` E`                                                                                   | ` `[pollFirst](https://developer.android.com/reference/java/util/LinkedList#pollFirst())`() ` Retrieves and removes the first element of this list, or returns`null`if this list is empty.                                                                                                                                                                                           |
| ` E`                                                                                   | ` `[pollLast](https://developer.android.com/reference/java/util/LinkedList#pollLast())`() ` Retrieves and removes the last element of this list, or returns`null`if this list is empty.                                                                                                                                                                                              |
| ` E`                                                                                   | ` `[pop](https://developer.android.com/reference/java/util/LinkedList#pop())`() ` Pops an element from the stack represented by this list.                                                                                                                                                                                                                                           |
| ` void`                                                                                | ` `[push](https://developer.android.com/reference/java/util/LinkedList#push(E))`(E e) ` Pushes an element onto the stack represented by this list.                                                                                                                                                                                                                                   |
| ` E`                                                                                   | ` `[remove](https://developer.android.com/reference/java/util/LinkedList#remove(int))`(int index) ` Removes the element at the specified position in this list.                                                                                                                                                                                                                      |
| ` E`                                                                                   | ` `[remove](https://developer.android.com/reference/java/util/LinkedList#remove())`() ` Retrieves and removes the head (first element) of this list.                                                                                                                                                                                                                                 |
| ` boolean`                                                                             | ` `[remove](https://developer.android.com/reference/java/util/LinkedList#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the first occurrence of the specified element from this list, if it is present.                                                                                                                |
| ` E`                                                                                   | ` `[removeFirst](https://developer.android.com/reference/java/util/LinkedList#removeFirst())`() ` Removes and returns the first element from this list.                                                                                                                                                                                                                              |
| ` boolean`                                                                             | ` `[removeFirstOccurrence](https://developer.android.com/reference/java/util/LinkedList#removeFirstOccurrence(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the first occurrence of the specified element in this list (when traversing the list from head to tail).                                                         |
| ` E`                                                                                   | ` `[removeLast](https://developer.android.com/reference/java/util/LinkedList#removeLast())`() ` Removes and returns the last element from this list.                                                                                                                                                                                                                                 |
| ` boolean`                                                                             | ` `[removeLastOccurrence](https://developer.android.com/reference/java/util/LinkedList#removeLastOccurrence(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the last occurrence of the specified element in this list (when traversing the list from head to tail).                                                            |
| ` `[LinkedList](https://developer.android.com/reference/java/util/LinkedList)`<E>`     | ` `[reversed](https://developer.android.com/reference/java/util/LinkedList#reversed())`() ` Returns a reverse-ordered[view](https://developer.android.com/reference/java/util/Collection#view)of this collection. Modifications to the reversed view are permitted and will be propagated to this list.                                                                              |
| ` E`                                                                                   | ` `[set](https://developer.android.com/reference/java/util/LinkedList#set(int,%20E))`(int index, E element) ` Replaces the element at the specified position in this list with the specified element.                                                                                                                                                                                |
| ` int`                                                                                 | ` `[size](https://developer.android.com/reference/java/util/LinkedList#size())`() ` Returns the number of elements in this list.                                                                                                                                                                                                                                                     |
| ` `[Spliterator](https://developer.android.com/reference/java/util/Spliterator)`<E>`   | ` `[spliterator](https://developer.android.com/reference/java/util/LinkedList#spliterator())`() ` Creates a*[late-binding](https://developer.android.com/reference/java/util/Spliterator#binding)* and*fail-fast* [Spliterator](https://developer.android.com/reference/java/util/Spliterator)over the elements in this list.                                                        |
| ` `[Object[]](https://developer.android.com/reference/java/lang/Object)                | ` `[toArray](https://developer.android.com/reference/java/util/LinkedList#toArray())`() ` Returns an array containing all of the elements in this list in proper sequence (from first to last element).                                                                                                                                                                              |
| ` <T> T[]`                                                                             | ` `[toArray](https://developer.android.com/reference/java/util/LinkedList#toArray(T[]))`(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.                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.AbstractSequentialList](https://developer.android.com/reference/java/util/AbstractSequentialList)` ` |-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                         | ` `[add](https://developer.android.com/reference/java/util/AbstractSequentialList#add(int,%20E))`(int index, E element) ` Inserts the specified element at the specified position in this list (optional operation).                                                                                                                                                         | | ` boolean`                                                                                      | ` `[addAll](https://developer.android.com/reference/java/util/AbstractSequentialList#addAll(int,%20java.util.Collection<?%20extends%20E>))`(int index, `[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Inserts all of the elements in the specified collection into this list at the specified position (optional operation). | | ` E`                                                                                            | ` `[get](https://developer.android.com/reference/java/util/AbstractSequentialList#get(int))`(int index) ` Returns the element at the specified position in this list.                                                                                                                                                                                                        | | ` `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`                  | ` `[iterator](https://developer.android.com/reference/java/util/AbstractSequentialList#iterator())`() ` Returns an iterator over the elements in this list (in proper sequence).                                                                                                                                                                                             | | ` abstract `[ListIterator](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/AbstractSequentialList#listIterator(int))`(int index) ` Returns a list iterator over the elements in this list (in proper sequence).                                                                                                                                                                     | | ` E`                                                                                            | ` `[remove](https://developer.android.com/reference/java/util/AbstractSequentialList#remove(int))`(int index) ` Removes the element at the specified position in this list (optional operation).                                                                                                                                                                             | | ` E`                                                                                            | ` `[set](https://developer.android.com/reference/java/util/AbstractSequentialList#set(int,%20E))`(int index, E element) ` Replaces the element at the specified position in this list with the specified element (optional operation).                                                                                                                                       | ||
| From class` `[java.util.AbstractList](https://developer.android.com/reference/java/util/AbstractList)` ` |----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                | ` `[add](https://developer.android.com/reference/java/util/AbstractList#add(int,%20E))`(int index, E element) ` Inserts the specified element at the specified position in this list (optional operation).                                                                                                                                                         | | ` boolean`                                                                             | ` `[add](https://developer.android.com/reference/java/util/AbstractList#add(E))`(E e) ` Appends the specified element to the end of this list (optional operation).                                                                                                                                                                                                | | ` boolean`                                                                             | ` `[addAll](https://developer.android.com/reference/java/util/AbstractList#addAll(int,%20java.util.Collection<?%20extends%20E>))`(int index, `[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Inserts all of the elements in the specified collection into this list at the specified position (optional operation). | | ` void`                                                                                | ` `[clear](https://developer.android.com/reference/java/util/AbstractList#clear())`() ` Removes all of the elements from this list (optional operation).                                                                                                                                                                                                           | | ` boolean`                                                                             | ` `[equals](https://developer.android.com/reference/java/util/AbstractList#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Compares the specified object with this list for equality.                                                                                                                         | | ` abstract E`                                                                          | ` `[get](https://developer.android.com/reference/java/util/AbstractList#get(int))`(int index) ` Returns the element at the specified position in this list.                                                                                                                                                                                                        | | ` int`                                                                                 | ` `[hashCode](https://developer.android.com/reference/java/util/AbstractList#hashCode())`() ` Returns the hash code value for this list.                                                                                                                                                                                                                           | | ` int`                                                                                 | ` `[indexOf](https://developer.android.com/reference/java/util/AbstractList#indexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.                                                | | ` `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`         | ` `[iterator](https://developer.android.com/reference/java/util/AbstractList#iterator())`() ` Returns an iterator over the elements in this list in proper sequence.                                                                                                                                                                                               | | ` int`                                                                                 | ` `[lastIndexOf](https://developer.android.com/reference/java/util/AbstractList#lastIndexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` 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](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/AbstractList#listIterator(int))`(int index) ` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.                                                                                                                     | | ` `[ListIterator](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/AbstractList#listIterator())`() ` Returns a list iterator over the elements in this list (in proper sequence).                                                                                                                                                                                 | | ` E`                                                                                   | ` `[remove](https://developer.android.com/reference/java/util/AbstractList#remove(int))`(int index) ` Removes the element at the specified position in this list (optional operation).                                                                                                                                                                             | | ` void`                                                                                | ` `[removeRange](https://developer.android.com/reference/java/util/AbstractList#removeRange(int,%20int))`(int fromIndex, int toIndex) ` Removes from this list all of the elements whose index is between`fromIndex`, inclusive, and`toIndex`, exclusive.                                                                                                          | | ` E`                                                                                   | ` `[set](https://developer.android.com/reference/java/util/AbstractList#set(int,%20E))`(int index, E element) ` Replaces the element at the specified position in this list with the specified element (optional operation).                                                                                                                                       | | ` `[List](https://developer.android.com/reference/java/util/List)`<E>`                 | ` `[subList](https://developer.android.com/reference/java/util/AbstractList#subList(int,%20int))`(int fromIndex, int toIndex) ` Returns a view of the portion of this list between the specified`fromIndex`, inclusive, and`toIndex`, exclusive.                                                                                                                   | ||
| From class` `[java.util.AbstractCollection](https://developer.android.com/reference/java/util/AbstractCollection)` ` |-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean`                                                                              | ` `[add](https://developer.android.com/reference/java/util/AbstractCollection#add(E))`(E e) ` Ensures that this collection contains the specified element (optional operation).                                                                                                                                                   | | ` boolean`                                                                              | ` `[addAll](https://developer.android.com/reference/java/util/AbstractCollection#addAll(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Adds all of the elements in the specified collection to this collection (optional operation).     | | ` void`                                                                                 | ` `[clear](https://developer.android.com/reference/java/util/AbstractCollection#clear())`() ` Removes all of the elements from this collection (optional operation).                                                                                                                                                              | | ` boolean`                                                                              | ` `[contains](https://developer.android.com/reference/java/util/AbstractCollection#contains(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns`true`if this collection contains the specified element.                                                                         | | ` boolean`                                                                              | ` `[containsAll](https://developer.android.com/reference/java/util/AbstractCollection#containsAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Returns`true`if this collection contains all of the elements in the specified collection.                       | | ` boolean`                                                                              | ` `[isEmpty](https://developer.android.com/reference/java/util/AbstractCollection#isEmpty())`() ` Returns`true`if this collection contains no elements.                                                                                                                                                                           | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>` | ` `[iterator](https://developer.android.com/reference/java/util/AbstractCollection#iterator())`() ` Returns an iterator over the elements contained in this collection.                                                                                                                                                           | | ` boolean`                                                                              | ` `[remove](https://developer.android.com/reference/java/util/AbstractCollection#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes a single instance of the specified element from this collection, if it is present (optional operation).                             | | ` boolean`                                                                              | ` `[removeAll](https://developer.android.com/reference/java/util/AbstractCollection#removeAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Removes all of this collection's elements that are also contained in the specified collection (optional operation). | | ` boolean`                                                                              | ` `[retainAll](https://developer.android.com/reference/java/util/AbstractCollection#retainAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Retains only the elements in this collection that are contained in the specified collection (optional operation).   | | ` abstract int`                                                                         | ` `[size](https://developer.android.com/reference/java/util/AbstractCollection#size())`() ` Returns the number of elements in this collection.                                                                                                                                                                                    | | ` <T> T[]`                                                                              | ` `[toArray](https://developer.android.com/reference/java/util/AbstractCollection#toArray(T[]))`(T[] a) ` Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.                                                                              | | ` `[Object[]](https://developer.android.com/reference/java/lang/Object)                 | ` `[toArray](https://developer.android.com/reference/java/util/AbstractCollection#toArray())`() ` Returns an array containing all of the elements in this collection.                                                                                                                                                             | | ` `[String](https://developer.android.com/reference/java/lang/String)                   | ` `[toString](https://developer.android.com/reference/java/util/AbstractCollection#toString())`() ` Returns a string representation of this collection.                                                                                                                                                                           | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.util.List](https://developer.android.com/reference/java/util/List)` ` |-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                             | ` `[add](https://developer.android.com/reference/java/util/List#add(E))`(E e) ` Appends the specified element to the end of this list (optional operation).                                                                                                                                                                                                                                           | | ` abstract void`                                                                                | ` `[add](https://developer.android.com/reference/java/util/List#add(int,%20E))`(int index, E element) ` Inserts the specified element at the specified position in this list (optional operation).                                                                                                                                                                                                    | | ` abstract boolean`                                                                             | ` `[addAll](https://developer.android.com/reference/java/util/List#addAll(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` 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 (optional operation).   | | ` abstract boolean`                                                                             | ` `[addAll](https://developer.android.com/reference/java/util/List#addAll(int,%20java.util.Collection<?%20extends%20E>))`(int index, `[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Inserts all of the elements in the specified collection into this list at the specified position (optional operation).                                            | | ` default void`                                                                                 | ` `[addFirst](https://developer.android.com/reference/java/util/List#addFirst(E))`(E e) ` Adds an element as the first element of this collection (optional operation).                                                                                                                                                                                                                               | | ` default void`                                                                                 | ` `[addLast](https://developer.android.com/reference/java/util/List#addLast(E))`(E e) ` Adds an element as the last element of this collection (optional operation).                                                                                                                                                                                                                                  | | ` abstract void`                                                                                | ` `[clear](https://developer.android.com/reference/java/util/List#clear())`() ` Removes all of the elements from this list (optional operation).                                                                                                                                                                                                                                                      | | ` abstract boolean`                                                                             | ` `[contains](https://developer.android.com/reference/java/util/List#contains(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns`true`if this list contains the specified element.                                                                                                                                                                 | | ` abstract boolean`                                                                             | ` `[containsAll](https://developer.android.com/reference/java/util/List#containsAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Returns`true`if this list contains all of the elements of the specified collection.                                                                                                               | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[copyOf](https://developer.android.com/reference/java/util/List#copyOf(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> coll) ` Returns an[unmodifiable List](https://developer.android.com/reference/java/util/LinkedList#unmodifiable)containing the elements of the given Collection, in its iteration order. | | ` abstract boolean`                                                                             | ` `[equals](https://developer.android.com/reference/java/util/List#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Compares the specified object with this list for equality.                                                                                                                                                                    | | ` abstract E`                                                                                   | ` `[get](https://developer.android.com/reference/java/util/List#get(int))`(int index) ` Returns the element at the specified position in this list.                                                                                                                                                                                                                                                   | | ` default E`                                                                                    | ` `[getFirst](https://developer.android.com/reference/java/util/List#getFirst())`() ` Gets the first element of this collection.                                                                                                                                                                                                                                                                      | | ` default E`                                                                                    | ` `[getLast](https://developer.android.com/reference/java/util/List#getLast())`() ` Gets the last element of this collection.                                                                                                                                                                                                                                                                         | | ` abstract int`                                                                                 | ` `[hashCode](https://developer.android.com/reference/java/util/List#hashCode())`() ` Returns the hash code value for this list.                                                                                                                                                                                                                                                                      | | ` abstract int`                                                                                 | ` `[indexOf](https://developer.android.com/reference/java/util/List#indexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.                                                                                           | | ` abstract boolean`                                                                             | ` `[isEmpty](https://developer.android.com/reference/java/util/List#isEmpty())`() ` Returns`true`if this list contains no elements.                                                                                                                                                                                                                                                                   | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`         | ` `[iterator](https://developer.android.com/reference/java/util/List#iterator())`() ` Returns an iterator over the elements in this list in proper sequence.                                                                                                                                                                                                                                          | | ` abstract int`                                                                                 | ` `[lastIndexOf](https://developer.android.com/reference/java/util/List#lastIndexOf(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.                                                                                    | | ` abstract `[ListIterator](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/List#listIterator(int))`(int index) ` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.                                                                                                                                                                | | ` abstract `[ListIterator](https://developer.android.com/reference/java/util/ListIterator)`<E>` | ` `[listIterator](https://developer.android.com/reference/java/util/List#listIterator())`() ` Returns a list iterator over the elements in this list (in proper sequence).                                                                                                                                                                                                                            | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E))`(E e1, E e2, E e3) ` Returns an unmodifiable list containing three elements.                                                                                                                                                                                                                                          | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) ` Returns an unmodifiable list containing nine elements.                                                                                                                                                                         | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5) ` Returns an unmodifiable list containing five elements.                                                                                                                                                                                                                     | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5, E e6) ` Returns an unmodifiable list containing six elements.                                                                                                                                                                                                           | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) ` Returns an unmodifiable list containing eight elements.                                                                                                                                                                                   | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E[]))`(E... elements) ` Returns an unmodifiable list containing an arbitrary number of elements.                                                                                                                                                                                                                                    | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of())`() ` Returns an unmodifiable list containing zero elements.                                                                                                                                                                                                                                                                      | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E,%20E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) ` Returns an unmodifiable list containing ten elements.                                                                                                                                                              | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E))`(E e1, E e2) ` Returns an unmodifiable list containing two elements.                                                                                                                                                                                                                                                       | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4, E e5, E e6, E e7) ` Returns an unmodifiable list containing seven elements.                                                                                                                                                                                              | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E,%20E,%20E,%20E))`(E e1, E e2, E e3, E e4) ` Returns an unmodifiable list containing four elements.                                                                                                                                                                                                                                | | ` static <E> `[List](https://developer.android.com/reference/java/util/List)`<E>`               | ` `[of](https://developer.android.com/reference/java/util/List#of(E))`(E e1) ` Returns an unmodifiable list containing one element.                                                                                                                                                                                                                                                                   | | ` abstract E`                                                                                   | ` `[remove](https://developer.android.com/reference/java/util/List#remove(int))`(int index) ` Removes the element at the specified position in this list (optional operation).                                                                                                                                                                                                                        | | ` abstract boolean`                                                                             | ` `[remove](https://developer.android.com/reference/java/util/List#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the first occurrence of the specified element from this list, if it is present (optional operation).                                                                                                                  | | ` abstract boolean`                                                                             | ` `[removeAll](https://developer.android.com/reference/java/util/List#removeAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Removes from this list all of its elements that are contained in the specified collection (optional operation).                                                                                       | | ` default E`                                                                                    | ` `[removeFirst](https://developer.android.com/reference/java/util/List#removeFirst())`() ` Removes and returns the first element of this collection (optional operation).                                                                                                                                                                                                                            | | ` default E`                                                                                    | ` `[removeLast](https://developer.android.com/reference/java/util/List#removeLast())`() ` Removes and returns the last element of this collection (optional operation).                                                                                                                                                                                                                               | | ` default void`                                                                                 | ` `[replaceAll](https://developer.android.com/reference/java/util/List#replaceAll(java.util.function.UnaryOperator<E>))`(`[UnaryOperator](https://developer.android.com/reference/java/util/function/UnaryOperator)`<E> operator) ` Replaces each element of this list with the result of applying the operator to that element.                                                                      | | ` abstract boolean`                                                                             | ` `[retainAll](https://developer.android.com/reference/java/util/List#retainAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Retains only the elements in this list that are contained in the specified collection (optional operation).                                                                                           | | ` default `[List](https://developer.android.com/reference/java/util/List)`<E>`                  | ` `[reversed](https://developer.android.com/reference/java/util/List#reversed())`() ` Returns a reverse-ordered[view](https://developer.android.com/reference/java/util/Collection#view)of this collection.                                                                                                                                                                                           | | ` abstract E`                                                                                   | ` `[set](https://developer.android.com/reference/java/util/List#set(int,%20E))`(int index, E element) ` Replaces the element at the specified position in this list with the specified element (optional operation).                                                                                                                                                                                  | | ` abstract int`                                                                                 | ` `[size](https://developer.android.com/reference/java/util/List#size())`() ` Returns the number of elements in this list.                                                                                                                                                                                                                                                                            | | ` default void`                                                                                 | ` `[sort](https://developer.android.com/reference/java/util/List#sort(java.util.Comparator<?%20super%20E>))`(`[Comparator](https://developer.android.com/reference/java/util/Comparator)`<? super E> c) ` Sorts this list according to the order induced by the specified[Comparator](https://developer.android.com/reference/java/util/Comparator).                                                  | | ` default `[Spliterator](https://developer.android.com/reference/java/util/Spliterator)`<E>`    | ` `[spliterator](https://developer.android.com/reference/java/util/List#spliterator())`() ` Creates a[Spliterator](https://developer.android.com/reference/java/util/Spliterator)over the elements in this list.                                                                                                                                                                                      | | ` abstract `[List](https://developer.android.com/reference/java/util/List)`<E>`                 | ` `[subList](https://developer.android.com/reference/java/util/List#subList(int,%20int))`(int fromIndex, int toIndex) ` Returns a view of the portion of this list between the specified`fromIndex`, inclusive, and`toIndex`, exclusive.                                                                                                                                                              | | ` abstract `[Object[]](https://developer.android.com/reference/java/lang/Object)                | ` `[toArray](https://developer.android.com/reference/java/util/List#toArray())`() ` Returns an array containing all of the elements in this list in proper sequence (from first to last element).                                                                                                                                                                                                     | | ` abstract <T> T[]`                                                                             | ` `[toArray](https://developer.android.com/reference/java/util/List#toArray(T[]))`(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.                                                                                                                      | ||
| From interface` `[java.util.Collection](https://developer.android.com/reference/java/util/Collection)` ` |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                          | ` `[add](https://developer.android.com/reference/java/util/Collection#add(E))`(E e) ` Ensures that this collection contains the specified element (optional operation).                                                                                                                                                                                                      | | ` abstract boolean`                                                                          | ` `[addAll](https://developer.android.com/reference/java/util/Collection#addAll(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Adds all of the elements in the specified collection to this collection (optional operation).                                                        | | ` abstract void`                                                                             | ` `[clear](https://developer.android.com/reference/java/util/Collection#clear())`() ` Removes all of the elements from this collection (optional operation).                                                                                                                                                                                                                 | | ` abstract boolean`                                                                          | ` `[contains](https://developer.android.com/reference/java/util/Collection#contains(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns`true`if this collection contains the specified element.                                                                                                                            | | ` abstract boolean`                                                                          | ` `[containsAll](https://developer.android.com/reference/java/util/Collection#containsAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Returns`true`if this collection contains all of the elements in the specified collection.                                                                          | | ` abstract boolean`                                                                          | ` `[equals](https://developer.android.com/reference/java/util/Collection#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Compares the specified object with this collection for equality.                                                                                                                               | | ` abstract int`                                                                              | ` `[hashCode](https://developer.android.com/reference/java/util/Collection#hashCode())`() ` Returns the hash code value for this collection.                                                                                                                                                                                                                                 | | ` abstract boolean`                                                                          | ` `[isEmpty](https://developer.android.com/reference/java/util/Collection#isEmpty())`() ` Returns`true`if this collection contains no elements.                                                                                                                                                                                                                              | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`      | ` `[iterator](https://developer.android.com/reference/java/util/Collection#iterator())`() ` Returns an iterator over the elements in this collection.                                                                                                                                                                                                                        | | ` default `[Stream](https://developer.android.com/reference/java/util/stream/Stream)`<E>`    | ` `[parallelStream](https://developer.android.com/reference/java/util/Collection#parallelStream())`() ` Returns a possibly parallel`Stream`with this collection as its source.                                                                                                                                                                                               | | ` abstract boolean`                                                                          | ` `[remove](https://developer.android.com/reference/java/util/Collection#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes a single instance of the specified element from this collection, if it is present (optional operation).                                                                                | | ` abstract boolean`                                                                          | ` `[removeAll](https://developer.android.com/reference/java/util/Collection#removeAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Removes all of this collection's elements that are also contained in the specified collection (optional operation).                                                    | | ` default boolean`                                                                           | ` `[removeIf](https://developer.android.com/reference/java/util/Collection#removeIf(java.util.function.Predicate<?%20super%20E>))`(`[Predicate](https://developer.android.com/reference/java/util/function/Predicate)`<? super E> filter) ` Removes all of the elements of this collection that satisfy the given predicate.                                                 | | ` abstract boolean`                                                                          | ` `[retainAll](https://developer.android.com/reference/java/util/Collection#retainAll(java.util.Collection<?>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<?> c) ` Retains only the elements in this collection that are contained in the specified collection (optional operation).                                                      | | ` abstract int`                                                                              | ` `[size](https://developer.android.com/reference/java/util/Collection#size())`() ` Returns the number of elements in this collection.                                                                                                                                                                                                                                       | | ` default `[Spliterator](https://developer.android.com/reference/java/util/Spliterator)`<E>` | ` `[spliterator](https://developer.android.com/reference/java/util/Collection#spliterator())`() ` Creates a[Spliterator](https://developer.android.com/reference/java/util/Spliterator)over the elements in this collection.                                                                                                                                                 | | ` default `[Stream](https://developer.android.com/reference/java/util/stream/Stream)`<E>`    | ` `[stream](https://developer.android.com/reference/java/util/Collection#stream())`() ` Returns a sequential`Stream`with this collection as its source.                                                                                                                                                                                                                      | | ` abstract <T> T[]`                                                                          | ` `[toArray](https://developer.android.com/reference/java/util/Collection#toArray(T[]))`(T[] a) ` Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.                                                                                                                                 | | ` abstract `[Object[]](https://developer.android.com/reference/java/lang/Object)             | ` `[toArray](https://developer.android.com/reference/java/util/Collection#toArray())`() ` Returns an array containing all of the elements in this collection.                                                                                                                                                                                                                | | ` default <T> T[]`                                                                           | ` `[toArray](https://developer.android.com/reference/java/util/Collection#toArray(java.util.function.IntFunction<T[]>))`(`[IntFunction](https://developer.android.com/reference/java/util/function/IntFunction)`<T[]> generator) ` Returns an array containing all of the elements in this collection, using the provided`generator`function to allocate the returned array. | ||
| From interface` `[java.util.Deque](https://developer.android.com/reference/java/util/Deque)` ` |-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                     | ` `[add](https://developer.android.com/reference/java/util/Deque#add(E))`(E e) ` Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning`true`upon success and throwing an`IllegalStateException`if no space is currently available.                                                                                        | | ` abstract boolean`                                                                     | ` `[addAll](https://developer.android.com/reference/java/util/Deque#addAll(java.util.Collection<?%20extends%20E>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<? extends E> c) ` Adds all of the elements in the specified collection at the end of this deque, as if by calling[addLast(E)](https://developer.android.com/reference/java/util/Deque#addLast(E))on each one, in the order that they are returned by the collection's iterator. | | ` abstract void`                                                                        | ` `[addFirst](https://developer.android.com/reference/java/util/Deque#addFirst(E))`(E e) ` Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an`IllegalStateException`if no space is currently available.                                                                                                                                                                        | | ` abstract void`                                                                        | ` `[addLast](https://developer.android.com/reference/java/util/Deque#addLast(E))`(E e) ` Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an`IllegalStateException`if no space is currently available.                                                                                                                                                                            | | ` abstract boolean`                                                                     | ` `[contains](https://developer.android.com/reference/java/util/Deque#contains(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Returns`true`if this deque contains the specified element.                                                                                                                                                                                                                                          | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>` | ` `[descendingIterator](https://developer.android.com/reference/java/util/Deque#descendingIterator())`() ` Returns an iterator over the elements in this deque in reverse sequential order.                                                                                                                                                                                                                                                                                      | | ` abstract E`                                                                           | ` `[element](https://developer.android.com/reference/java/util/Deque#element())`() ` Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).                                                                                                                                                                                                                                                          | | ` abstract E`                                                                           | ` `[getFirst](https://developer.android.com/reference/java/util/Deque#getFirst())`() ` Retrieves, but does not remove, the first element of this deque.                                                                                                                                                                                                                                                                                                                          | | ` abstract E`                                                                           | ` `[getLast](https://developer.android.com/reference/java/util/Deque#getLast())`() ` Retrieves, but does not remove, the last element of this deque.                                                                                                                                                                                                                                                                                                                             | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>` | ` `[iterator](https://developer.android.com/reference/java/util/Deque#iterator())`() ` Returns an iterator over the elements in this deque in proper sequence.                                                                                                                                                                                                                                                                                                                   | | ` abstract boolean`                                                                     | ` `[offer](https://developer.android.com/reference/java/util/Deque#offer(E))`(E e) ` Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning`true`upon success and`false`if no space is currently available.                                                                                                                | | ` abstract boolean`                                                                     | ` `[offerFirst](https://developer.android.com/reference/java/util/Deque#offerFirst(E))`(E e) ` Inserts the specified element at the front of this deque unless it would violate capacity restrictions.                                                                                                                                                                                                                                                                           | | ` abstract boolean`                                                                     | ` `[offerLast](https://developer.android.com/reference/java/util/Deque#offerLast(E))`(E e) ` Inserts the specified element at the end of this deque unless it would violate capacity restrictions.                                                                                                                                                                                                                                                                               | | ` abstract E`                                                                           | ` `[peek](https://developer.android.com/reference/java/util/Deque#peek())`() ` Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns`null`if this deque is empty.                                                                                                                                                                                                                        | | ` abstract E`                                                                           | ` `[peekFirst](https://developer.android.com/reference/java/util/Deque#peekFirst())`() ` Retrieves, but does not remove, the first element of this deque, or returns`null`if this deque is empty.                                                                                                                                                                                                                                                                                | | ` abstract E`                                                                           | ` `[peekLast](https://developer.android.com/reference/java/util/Deque#peekLast())`() ` Retrieves, but does not remove, the last element of this deque, or returns`null`if this deque is empty.                                                                                                                                                                                                                                                                                   | | ` abstract E`                                                                           | ` `[poll](https://developer.android.com/reference/java/util/Deque#poll())`() ` Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns`null`if this deque is empty.                                                                                                                                                                                                                                  | | ` abstract E`                                                                           | ` `[pollFirst](https://developer.android.com/reference/java/util/Deque#pollFirst())`() ` Retrieves and removes the first element of this deque, or returns`null`if this deque is empty.                                                                                                                                                                                                                                                                                          | | ` abstract E`                                                                           | ` `[pollLast](https://developer.android.com/reference/java/util/Deque#pollLast())`() ` Retrieves and removes the last element of this deque, or returns`null`if this deque is empty.                                                                                                                                                                                                                                                                                             | | ` abstract E`                                                                           | ` `[pop](https://developer.android.com/reference/java/util/Deque#pop())`() ` Pops an element from the stack represented by this deque.                                                                                                                                                                                                                                                                                                                                           | | ` abstract void`                                                                        | ` `[push](https://developer.android.com/reference/java/util/Deque#push(E))`(E e) ` Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an`IllegalStateException`if no space is currently available.                                                                                                                                  | | ` abstract E`                                                                           | ` `[remove](https://developer.android.com/reference/java/util/Deque#remove())`() ` Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).                                                                                                                                                                                                                                                                      | | ` abstract boolean`                                                                     | ` `[remove](https://developer.android.com/reference/java/util/Deque#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the first occurrence of the specified element from this deque.                                                                                                                                                                                                                                  | | ` abstract E`                                                                           | ` `[removeFirst](https://developer.android.com/reference/java/util/Deque#removeFirst())`() ` Retrieves and removes the first element of this deque.                                                                                                                                                                                                                                                                                                                              | | ` abstract boolean`                                                                     | ` `[removeFirstOccurrence](https://developer.android.com/reference/java/util/Deque#removeFirstOccurrence(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the first occurrence of the specified element from this deque.                                                                                                                                                                                                    | | ` abstract E`                                                                           | ` `[removeLast](https://developer.android.com/reference/java/util/Deque#removeLast())`() ` Retrieves and removes the last element of this deque.                                                                                                                                                                                                                                                                                                                                 | | ` abstract boolean`                                                                     | ` `[removeLastOccurrence](https://developer.android.com/reference/java/util/Deque#removeLastOccurrence(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Removes the last occurrence of the specified element from this deque.                                                                                                                                                                                                       | | ` default `[Deque](https://developer.android.com/reference/java/util/Deque)`<E>`        | ` `[reversed](https://developer.android.com/reference/java/util/Deque#reversed())`() ` Returns a reverse-ordered[view](https://developer.android.com/reference/java/util/Collection#view)of this collection.                                                                                                                                                                                                                                                                     | | ` abstract int`                                                                         | ` `[size](https://developer.android.com/reference/java/util/Deque#size())`() ` Returns the number of elements in this deque.                                                                                                                                                                                                                                                                                                                                                     | ||
| From interface` `[java.util.SequencedCollection](https://developer.android.com/reference/java/util/SequencedCollection)` ` |---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`                                                                                               | ` `[addFirst](https://developer.android.com/reference/java/util/SequencedCollection#addFirst(E))`(E e) ` Adds an element as the first element of this collection (optional operation).                                     | | ` default void`                                                                                               | ` `[addLast](https://developer.android.com/reference/java/util/SequencedCollection#addLast(E))`(E e) ` Adds an element as the last element of this collection (optional operation).                                        | | ` default E`                                                                                                  | ` `[getFirst](https://developer.android.com/reference/java/util/SequencedCollection#getFirst())`() ` Gets the first element of this collection.                                                                            | | ` default E`                                                                                                  | ` `[getLast](https://developer.android.com/reference/java/util/SequencedCollection#getLast())`() ` Gets the last element of this collection.                                                                               | | ` default E`                                                                                                  | ` `[removeFirst](https://developer.android.com/reference/java/util/SequencedCollection#removeFirst())`() ` Removes and returns the first element of this collection (optional operation).                                  | | ` default E`                                                                                                  | ` `[removeLast](https://developer.android.com/reference/java/util/SequencedCollection#removeLast())`() ` Removes and returns the last element of this collection (optional operation).                                     | | ` abstract `[SequencedCollection](https://developer.android.com/reference/java/util/SequencedCollection)`<E>` | ` `[reversed](https://developer.android.com/reference/java/util/SequencedCollection#reversed())`() ` Returns a reverse-ordered[view](https://developer.android.com/reference/java/util/Collection#view)of this collection. | ||
| From interface` `[java.lang.Iterable](https://developer.android.com/reference/java/lang/Iterable)` ` |----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`                                                                              | ` `[forEach](https://developer.android.com/reference/java/lang/Iterable#forEach(java.util.function.Consumer<?%20super%20T>))`(`[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<? super T> action) ` Performs the given action for each element of the`Iterable`until all elements have been processed or the action throws an exception. | | ` abstract `[Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>`      | ` `[iterator](https://developer.android.com/reference/java/lang/Iterable#iterator())`() ` Returns an iterator over elements of type`T`.                                                                                                                                                                                                                                   | | ` default `[Spliterator](https://developer.android.com/reference/java/util/Spliterator)`<E>` | ` `[spliterator](https://developer.android.com/reference/java/lang/Iterable#spliterator())`() ` Creates a[Spliterator](https://developer.android.com/reference/java/util/Spliterator)over the elements described by this`Iterable`.                                                                                                                                       | ||
| From interface` `[java.util.Queue](https://developer.android.com/reference/java/util/Queue)` ` |---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` `[add](https://developer.android.com/reference/java/util/Queue#add(E))`(E e) ` Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning`true`upon success and throwing an`IllegalStateException`if no space is currently available. | | ` abstract E`       | ` `[element](https://developer.android.com/reference/java/util/Queue#element())`() ` Retrieves, but does not remove, the head of this queue.                                                                                                                                                                         | | ` abstract boolean` | ` `[offer](https://developer.android.com/reference/java/util/Queue#offer(E))`(E e) ` Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.                                                                                                   | | ` abstract E`       | ` `[peek](https://developer.android.com/reference/java/util/Queue#peek())`() ` Retrieves, but does not remove, the head of this queue, or returns`null`if this queue is empty.                                                                                                                                       | | ` abstract E`       | ` `[poll](https://developer.android.com/reference/java/util/Queue#poll())`() ` Retrieves and removes the head of this queue, or returns`null`if this queue is empty.                                                                                                                                                 | | ` abstract E`       | ` `[remove](https://developer.android.com/reference/java/util/Queue#remove())`() ` Retrieves and removes the head of this queue.                                                                                                                                                                                     | ||

## Public constructors

### LinkedList

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LinkedList ()
```

Constructs an empty list.

<br />

### LinkedList

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LinkedList (Collection<? extends E> c)
```

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

<br />

|                                       Parameters                                        ||
|-----|------------------------------------------------------------------------------------|
| `c` | `Collection`: the collection whose elements are to be placed into this list <br /> |

|                                                               Throws                                                                ||
|------------------------------------------------------------------------------------------------|-------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified collection is null |

## Public methods

### add

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean add (E e)
```

Appends the specified element to the end of this list.

This method is equivalent to[addLast(E)](https://developer.android.com/reference/java/util/LinkedList#addLast(E)).

<br />

|                      Parameters                      ||
|-----|-------------------------------------------------|
| `e` | `E`: element to be appended to this list <br /> |

|                                                            Returns                                                             ||
|-----------|---------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`(as specified by[Collection.add](https://developer.android.com/reference/java/util/Collection#add(E))) <br /> |

### add

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void add (int index, 
                E element)
```

Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

<br />

|                                   Parameters                                    ||
|-----------|----------------------------------------------------------------------|
| `index`   | `int`: index at which the specified element is to be inserted <br /> |
| `element` | `E`: element to be inserted <br />                                   |

|                                                   Throws                                                    ||
|----------------------------------------------------------------------------------------------------------|---|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |   |

### addAll

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean addAll (Collection<? extends E> c)
```

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. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

<br />

|                                    Parameters                                     ||
|-----|------------------------------------------------------------------------------|
| `c` | `Collection`: collection containing elements to be added to this list <br /> |

|                               Returns                                ||
|-----------|-----------------------------------------------------------|
| `boolean` | `true`if this list changed as a result of the call <br /> |

|                                                               Throws                                                                ||
|------------------------------------------------------------------------------------------------|-------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified collection is null |

### addAll

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean addAll (int index, 
                Collection<? extends E> c)
```

Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.

<br />

|                                           Parameters                                            ||
|---------|----------------------------------------------------------------------------------------|
| `index` | `int`: index at which to insert the first element from the specified collection <br /> |
| `c`     | `Collection`: collection containing elements to be added to this list <br />           |

|                               Returns                                ||
|-----------|-----------------------------------------------------------|
| `boolean` | `true`if this list changed as a result of the call <br /> |

|                                                                    Throws                                                                     ||
|----------------------------------------------------------------------------------------------------------|-------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |                                     |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)           | if the specified collection is null |

### addFirst

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void addFirst (E e)
```

Inserts the specified element at the beginning of this list.

<br />

|             Parameters              ||
|-----|--------------------------------|
| `e` | `E`: the element to add <br /> |

### addLast

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void addLast (E e)
```

Appends the specified element to the end of this list.

This method is equivalent to[add(E)](https://developer.android.com/reference/java/util/LinkedList#add(E)).

<br />

|             Parameters              ||
|-----|--------------------------------|
| `e` | `E`: the element to add <br /> |

### clear

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void clear ()
```

Removes all of the elements from this list. The list will be empty after this call returns.

<br />

### clone

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object clone ()
```

Returns a shallow copy of this`LinkedList`. (The elements themselves are not cloned.)

<br />

|                                                        Returns                                                        ||
|--------------------------------------------------------------------|---------------------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | a shallow copy of this`LinkedList`instance <br /> |

### contains

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean contains (Object o)
```

Returns`true`if this list contains the specified element. More formally, returns`true`if and only if this list contains at least one element`e`such that`Objects.equals(o, e)`.

<br />

|                                Parameters                                 ||
|-----|----------------------------------------------------------------------|
| `o` | `Object`: element whose presence in this list is to be tested <br /> |

|                               Returns                               ||
|-----------|----------------------------------------------------------|
| `boolean` | `true`if this list contains the specified element <br /> |

### descendingIterator

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Iterator<E> descendingIterator ()
```

Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).

<br />

|                                                                       Returns                                                                       ||
|-----------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Iterator](https://developer.android.com/reference/java/util/Iterator)`<E>` | an iterator over the elements in this deque in reverse sequence <br /> |

### element

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E element ()
```

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

<br />

|              Returns              ||
|-----|------------------------------|
| `E` | the head of this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### get

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E get (int index)
```

Returns the element at the specified position in this list.

<br />

|                      Parameters                       ||
|---------|----------------------------------------------|
| `index` | `int`: index of the element to return <br /> |

|                            Returns                             ||
|-----|-----------------------------------------------------------|
| `E` | the element at the specified position in this list <br /> |

|                                                   Throws                                                    ||
|----------------------------------------------------------------------------------------------------------|---|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |   |

### getFirst

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E getFirst ()
```

Returns the first element in this list.

<br />

|                  Returns                   ||
|-----|---------------------------------------|
| `E` | the first element in this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### getLast

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E getLast ()
```

Returns the last element in this list.

<br />

|                  Returns                  ||
|-----|--------------------------------------|
| `E` | the last element in this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### indexOf

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int indexOf (Object o)
```

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index`i`such that`Objects.equals(o, get(i))`, or -1 if there is no such index.

<br />

|                 Parameters                  ||
|-----|----------------------------------------|
| `o` | `Object`: element to search for <br /> |

|                                                                Returns                                                                 ||
|-------|---------------------------------------------------------------------------------------------------------------------------------|
| `int` | the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element <br /> |

### lastIndexOf

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int lastIndexOf (Object o)
```

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index`i`such that`Objects.equals(o, get(i))`, or -1 if there is no such index.

<br />

|                 Parameters                  ||
|-----|----------------------------------------|
| `o` | `Object`: element to search for <br /> |

|                                                                Returns                                                                ||
|-------|--------------------------------------------------------------------------------------------------------------------------------|
| `int` | the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element <br /> |

### listIterator

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ListIterator<E> listIterator (int index)
```

Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. Obeys the general contract of`List.listIterator(int)`.

The list-iterator is*fail-fast* : if the list is structurally modified at any time after the Iterator is created, in any way except through the list-iterator's own`remove`or`add`methods, the list-iterator will throw a`ConcurrentModificationException`. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

<br />

|                                                  Parameters                                                  ||
|---------|-----------------------------------------------------------------------------------------------------|
| `index` | `int`: index of the first element to be returned from the list-iterator (by a call to`next`) <br /> |

|                                                                                                   Returns                                                                                                    ||
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| [ListIterator](https://developer.android.com/reference/java/util/ListIterator)`<E>` | a ListIterator of the elements in this list (in proper sequence), starting at the specified position in the list <br /> |

|                                                   Throws                                                    ||
|----------------------------------------------------------------------------------------------------------|---|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |   |

**See also:**

- [List.listIterator(int)](https://developer.android.com/reference/java/util/List#listIterator(int))  

### offer

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean offer (E e)
```

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

<br />

|             Parameters              ||
|-----|--------------------------------|
| `e` | `E`: the element to add <br /> |

|                                                         Returns                                                          ||
|-----------|---------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`(as specified by[Queue.offer](https://developer.android.com/reference/java/util/Queue#offer(E))) <br /> |

### offerFirst

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean offerFirst (E e)
```

Inserts the specified element at the front of this list.

<br />

|               Parameters               ||
|-----|-----------------------------------|
| `e` | `E`: the element to insert <br /> |

|                                                              Returns                                                               ||
|-----------|-------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`(as specified by[Deque.offerFirst](https://developer.android.com/reference/java/util/Deque#offerFirst(E))) <br /> |

### offerLast

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean offerLast (E e)
```

Inserts the specified element at the end of this list.

<br />

|               Parameters               ||
|-----|-----------------------------------|
| `e` | `E`: the element to insert <br /> |

|                                                             Returns                                                              ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`(as specified by[Deque.offerLast](https://developer.android.com/reference/java/util/Deque#offerLast(E))) <br /> |

### peek

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E peek ()
```

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

<br />

|                             Returns                              ||
|-----|-------------------------------------------------------------|
| `E` | the head of this list, or`null`if this list is empty <br /> |

### peekFirst

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E peekFirst ()
```

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

<br />

|                                  Returns                                  ||
|-----|----------------------------------------------------------------------|
| `E` | the first element of this list, or`null`if this list is empty <br /> |

### peekLast

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E peekLast ()
```

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

<br />

|                                 Returns                                  ||
|-----|---------------------------------------------------------------------|
| `E` | the last element of this list, or`null`if this list is empty <br /> |

### poll

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E poll ()
```

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

<br />

|                             Returns                              ||
|-----|-------------------------------------------------------------|
| `E` | the head of this list, or`null`if this list is empty <br /> |

### pollFirst

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E pollFirst ()
```

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

<br />

|                                  Returns                                  ||
|-----|----------------------------------------------------------------------|
| `E` | the first element of this list, or`null`if this list is empty <br /> |

### pollLast

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E pollLast ()
```

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

<br />

|                                 Returns                                  ||
|-----|---------------------------------------------------------------------|
| `E` | the last element of this list, or`null`if this list is empty <br /> |

### pop

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E pop ()
```

Pops an element from the stack represented by this list. In other words, removes and returns the first element of this list.

This method is equivalent to[removeFirst()](https://developer.android.com/reference/java/util/LinkedList#removeFirst()).

<br />

|                                                  Returns                                                   ||
|-----|-------------------------------------------------------------------------------------------------------|
| `E` | the element at the front of this list (which is the top of the stack represented by this list) <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### push

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void push (E e)
```

Pushes an element onto the stack represented by this list. In other words, inserts the element at the front of this list.

This method is equivalent to[addFirst(E)](https://developer.android.com/reference/java/util/LinkedList#addFirst(E)).

<br />

|              Parameters              ||
|-----|---------------------------------|
| `e` | `E`: the element to push <br /> |

### remove

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E remove (int index)
```

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

<br />

|                          Parameters                           ||
|---------|------------------------------------------------------|
| `index` | `int`: the index of the element to be removed <br /> |

|                           Returns                            ||
|-----|---------------------------------------------------------|
| `E` | the element previously at the specified position <br /> |

|                                                   Throws                                                    ||
|----------------------------------------------------------------------------------------------------------|---|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |   |

### remove

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E remove ()
```

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

<br />

|              Returns              ||
|-----|------------------------------|
| `E` | the head of this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### remove

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean remove (Object o)
```

Removes the first occurrence of the specified element from this list, if it is present. If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index`i`such that`Objects.equals(o, get(i))`(if such an element exists). Returns`true`if this list contained the specified element (or equivalently, if this list changed as a result of the call).

<br />

|                               Parameters                               ||
|-----|-------------------------------------------------------------------|
| `o` | `Object`: element to be removed from this list, if present <br /> |

|                               Returns                                ||
|-----------|-----------------------------------------------------------|
| `boolean` | `true`if this list contained the specified element <br /> |

### removeFirst

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E removeFirst ()
```

Removes and returns the first element from this list.

<br />

|                   Returns                    ||
|-----|-----------------------------------------|
| `E` | the first element from this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### removeFirstOccurrence

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean removeFirstOccurrence (Object o)
```

Removes the first occurrence of the specified element in this list (when traversing the list from head to tail). If the list does not contain the element, it is unchanged.

<br />

|                               Parameters                               ||
|-----|-------------------------------------------------------------------|
| `o` | `Object`: element to be removed from this list, if present <br /> |

|                               Returns                               ||
|-----------|----------------------------------------------------------|
| `boolean` | `true`if the list contained the specified element <br /> |

### removeLast

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E removeLast ()
```

Removes and returns the last element from this list.

<br />

|                   Returns                   ||
|-----|----------------------------------------|
| `E` | the last element from this list <br /> |

|                                                          Throws                                                           ||
|----------------------------------------------------------------------------------------------------|-----------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if this list is empty |

### removeLastOccurrence

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean removeLastOccurrence (Object o)
```

Removes the last occurrence of the specified element in this list (when traversing the list from head to tail). If the list does not contain the element, it is unchanged.

<br />

|                               Parameters                               ||
|-----|-------------------------------------------------------------------|
| `o` | `Object`: element to be removed from this list, if present <br /> |

|                               Returns                               ||
|-----------|----------------------------------------------------------|
| `boolean` | `true`if the list contained the specified element <br /> |

### reversed

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LinkedList<E> reversed ()
```

Returns a reverse-ordered[view](https://developer.android.com/reference/java/util/Collection#view)of this collection. The encounter order of elements in the returned view is the inverse of the encounter order of elements in this collection. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view. If the collection implementation permits modifications to this view, the modifications "write through" to the underlying collection. Changes to the underlying collection might or might not be visible in this reversed view, depending upon the implementation.

Modifications to the reversed view are permitted and will be propagated to this list. In addition, modifications to this list will be visible in the reversed view.

<br />

|                                                                    Returns                                                                     ||
|---------------------------------------------------------------------------------|---------------------------------------------------------------|
| [LinkedList](https://developer.android.com/reference/java/util/LinkedList)`<E>` | a reverse-ordered view of this collection, as a`Deque` <br /> |

### set

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public E set (int index, 
                E element)
```

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

<br />

|                              Parameters                               ||
|-----------|------------------------------------------------------------|
| `index`   | `int`: index of the element to replace <br />              |
| `element` | `E`: element to be stored at the specified position <br /> |

|                           Returns                            ||
|-----|---------------------------------------------------------|
| `E` | the element previously at the specified position <br /> |

|                                                   Throws                                                    ||
|----------------------------------------------------------------------------------------------------------|---|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) |   |

### size

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int size ()
```

Returns the number of elements in this list.

<br />

|                      Returns                      ||
|-------|--------------------------------------------|
| `int` | the number of elements in this list <br /> |

### spliterator

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Spliterator<E> spliterator ()
```

Creates a*[late-binding](https://developer.android.com/reference/java/util/Spliterator#binding)* and*fail-fast* [Spliterator](https://developer.android.com/reference/java/util/Spliterator)over the elements in this list.

The`Spliterator`reports[Spliterator.SIZED](https://developer.android.com/reference/java/util/Spliterator#SIZED)and[Spliterator.ORDERED](https://developer.android.com/reference/java/util/Spliterator#ORDERED). Overriding implementations should document the reporting of additional characteristic values.

<br />

##### Implementation Note:

- The`Spliterator`additionally reports[Spliterator.SUBSIZED](https://developer.android.com/reference/java/util/Spliterator#SUBSIZED)and implements`trySplit`to permit limited parallelism..

|                                                                Returns                                                                 ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------|
| [Spliterator](https://developer.android.com/reference/java/util/Spliterator)`<E>` | a`Spliterator`over the elements in this list <br /> |

### toArray

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object[] toArray ()
```

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

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

<br />

|                                                                       Returns                                                                        ||
|----------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [Object[]](https://developer.android.com/reference/java/lang/Object) | an array containing all of the elements in this list in proper sequence <br /> |

### toArray

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public 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. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to`null`. (This is useful in determining the length of the list*only*if the caller knows that the list does not contain any null elements.)

Like the[toArray()](https://developer.android.com/reference/java/util/LinkedList#toArray())method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose`x`is a list known to contain only strings. The following code can be used to dump the list into a newly allocated array of`String`:  

```
     String[] y = x.toArray(new String[0]);
```
Note that`toArray(new Object[0])`is identical in function to`toArray()`.

<br />

<br />

|                                                                                      Parameters                                                                                      ||
|-----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `a` | `T`: the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. <br /> |

|                          Returns                           ||
|-------|-----------------------------------------------------|
| `T[]` | an array containing the elements of the list <br /> |

|                                                                                                     Throws                                                                                                      ||
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| [ArrayStoreException](https://developer.android.com/reference/java/lang/ArrayStoreException)   | if the runtime type of the specified array is not a supertype of the runtime type of every element in this list |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified array is null                                                                                  |