The table below provides a comprehensive list of all LinkedList methods.
Certain methods utilize the type of the LinkedList’s items, denoted as T, either as a parameter or return value.
Method |
Description |
Return Type |
Add() |
Insert an element into the list. |
boolean|void |
Addall() |
Append a collection of elements to the list. |
boolean |
AddFirst() |
Prepends an item to the list. |
void |
addLast() |
Appends an item to the end of the list. |
void |
Clear() |
Clear the list, removing all items. |
void |
Clone() |
Generate a duplicate of the LinkedList. |
Object |
Contains() |
Verify if an item exists in the list. |
boolean |
descendingIterator() |
Returns an iterator to traverse the items of the list in reverse sequence. |
|
element() |
Fetches the initial item in the list, akin to the getFirst() method. |
|
forEach() |
Execute an action on each item within the list. |
void |
get() |
Retrieve the item located at a particular position within the list. |
T |
getFirst() |
Retrieves the initial item from the list. |
T |
getLast() |
Retrieves the final item from the list. |
T |
indexOf() |
Retrieve the index of the initial occurrence of an item within the list. |
int |
isEmpty() |
Verifies if the list is devoid of elements. |
boolean |
iterator() |
Provide an Iterator object for the LinkedList. |
Iterator |
lastIndexOf() |
Retrieve the index of the final occurrence of an item within the list. |
int |
listIterator() |
Provide a ListIterator object for the LinkedList. |
ListIterator |
listIterator() |
Appends an item to the end of the list. |
|
offerFirst() |
Prepends an item to the beginning of the list. |
|
offerLast() |
Appends an item to the end of the list. |
|
Peek() |
Retrieve the initial item in the list, similar to the getFirst() method. |
|
peekFirst() |
Retrieve the initial item in the list, akin to using peek(). |
|
peelLast() |
Retrieve the final item in the list. |
|
Poll() |
Retrieve and remove the initial item from the list. |
|
pollFirst() |
Retrieve and remove the initial item from the list, akin to using poll(). |
|
pollLast() |
Retrieve and remove the final item from the list. |
|
Pop() |
Retrieve the initial element in the list, similar to the removeFirst() method. |
|
Push() |
Prepends an item to the list, akin to using addFirst(). |
|
Remove() |
Delete an item from the list. |
boolean|T |
RemoveAll() |
Eliminate a collection of items from the list. |
boolean |
removeFirst() |
Remove the initial item from the list. |
T |
removeFirstOccurrence() |
Remove the initial occurrence of a specified item from the list. |
|
removeIf() |
Remove all items from the list that satisfy a specified condition. |
boolean |
removeLast() |
Remove the final item from the list. |
T |
removeLastOccurrence() |
Remove the final occurrence of a specified item from the list. |
|
replaceAll() |
Substitute each item in the list with the outcome of an operation performed on that item. |
void |
retainAll() |
Eliminate all elements from the list that are not part of a specified collection. |
boolean |
set() |
Substitute an item at a specified position within the list. |
T |
size() |
Retrieve the count of items in the list. |
int |
sort() |
Arrange the items in the list in ascending order. |
void |
spliterator() |
Provide a Spliterator object for the LinkedList. |
Spliterator |
subList() |
Return a sublist that grants access to a specified range of items within this list. |
List |
toArray() |
Return a sublist that grants access to a specified range of items within this list. |
Object[] |