LinkedList Methods Reference - Complete Reference with Syntax and Description
LinkedList Methods Reference - Complete Reference with Syntax and Description
Learn all the methods of Java LinkedList with usage syntax and beginner-friendly explanations. Ideal for learners and developers.
This reference explains LinkedList Methods Reference - Complete Reference with Syntax and Description through its syntax, examples and boundaries. Use the linked course lessons when the surrounding Java concepts are unfamiliar.
Use this reference
Identify the documented behavior, read a complete example and check its inputs before applying it.
LinkedList Methods Reference - Complete Reference with Syntax and Description
- add()
Adds an element to the end or inserts it at a specified position.public boolean add(E e) public void add(int index, E element)- addAll()
Adds all elements from a collection, optionally at a specific index.public boolean addAll(Collection extends E> c) public boolean addAll(int index, Collection extends E> c)- addFirst()
Inserts the element at the beginning of the list.public void addFirst(E e)- addLast()
Appends the element to the end of the list.public void addLast(E e)- clear()
Removes all elements, making the list empty.public void clear()- clone()
Returns a shallow copy of the LinkedList instance.public Object clone()- contains()
Checks if a specific element exists in the list.public boolean contains(Object o)- descendingIterator()
Returns an iterator that iterates the list in reverse order.public IteratordescendingIterator() - element()
Retrieves, but does not remove, the head of the list.public E element()- get()
Returns the element at the specified index.public E get(int index)- getFirst()
Retrieves the first element without removing it.public E getFirst()- getLast()
Retrieves the last element without removing it.public E getLast()- indexOf()
Returns the index of the first occurrence of the element.public int indexOf(Object o)- lastIndexOf()
Returns the index of the last occurrence of the element.public int lastIndexOf(Object o)- listIterator()
Returns a list iterator starting at the specified position.public ListIteratorlistIterator(int index) - offer()
Inserts the specified element at the end of the list.public boolean offer(E e)- offerFirst()
Inserts the element at the front of the list.public boolean offerFirst(E e)- offerLast()
Adds the element at the end of the list.public boolean offerLast(E e)- peek()
Retrieves the head of the list without removing it.public E peek()- peekFirst()
Retrieves the first element without removal.public E peekFirst()- peekLast()
Retrieves the last element without removal.public E peekLast()- poll()
Retrieves and removes the head of the list.public E poll()- pollFirst()
Retrieves and removes the first element of the list.public E pollFirst()- pollLast()
Retrieves and removes the last element of the list.public E pollLast()- pop()
Pops an element from the stack represented by the list.public E pop()- push()
Pushes an element onto the stack represented by the list.public void push(E e)- remove()
Removes and returns the first element or removes a specified element or index.public E remove() public E remove(int index) public boolean remove(Object o)- removeFirst()
Removes and returns the first element.public E removeFirst()- removeFirstOccurrence()
Removes the first occurrence of the specified element.public boolean removeFirstOccurrence(Object o)- removeLast()
Removes and returns the last element.public E removeLast()- removeLastOccurrence()
Removes the last occurrence of the specified element.public boolean removeLastOccurrence(Object o)- set()
Replaces the element at the specified position.public E set(int index, E element)- size()
Returns the number of elements in the list.public int size()- spliterator()
Creates a late-binding and fail-fast Spliterator.public Spliteratorspliterator() - toArray()
Returns an array containing all elements of the list.public Object[] toArray() publicT[] toArray(T[] a)
Using this reference
Check the example’s types, inputs and documented behavior before copying it into an application. Some APIs require external libraries, files or platform services; consult their setup notes.
Related explanations: Java Data Types - Primitive and Non-Primitive, Java Class - Blueprint of Objects, Exceptions in Java Introduction.
Supporting documentation: Official Java learning guide.
Reference checks are optional and do not count toward course progress.