Java – LinkedList Class

Java LinkedList Class methods, constructors, variables available in Java 8 release are listed below. We will publish example program on each methods ASAP.

Constructors in Java LinkedList Class

S.No Constructor & Description
1 LinkedList()

Constructs an empty list.
2 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.

Methods in Java LinkedList Class

S.No Method & Description
1 boolean add(E e)

Appends the specified element to the end of this list.
2 void add(int index, E element)

Inserts the specified element at the specified position in this list.
3 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.
4 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.
5 void addFirst(E e)

Inserts the specified element at the beginning of this list.
6 void addLast(E e)

Appends the specified element to the end of this list.
7 void clear()

Removes all of the elements from this list.
8 Object clone()

Returns a shallow copy of this LinkedList.
9 boolean contains(Object o)

Returns true if this list contains the specified element.
10 Iterator<E> descendingIterator()

Returns an iterator over the elements in this deque in reverse sequential order.
11 E element()

Retrieves, but does not remove, the head (first element) of this list.
12 E get(int index)

Returns the element at the specified position in this list.
13 E getFirst()

Returns the first element in this list.
14 E getLast()

Returns the last element in this list.
15 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.
16 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.
17 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.
18 boolean offer(E e)

Adds the specified element as the tail (last element) of this list.
19 boolean offerFirst(E e)

Inserts the specified element at the front of this list.
20 boolean offerLast(E e)

Inserts the specified element at the end of this list.
21 E peek()

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

Retrieves, but does not remove, the first element of this list, or returns null if this list is empty.
23 E peekLast()

Retrieves, but does not remove, the last element of this list, or returns null if this list is empty.
24 E poll()

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

Retrieves and removes the first element of this list, or returns null if this list is empty.
26 E pollLast()

Retrieves and removes the last element of this list, or returns null if this list is empty.
27 E pop()

Pops an element from the stack represented by this list.
28 void push(E e)

Pushes an element onto the stack represented by this list.
29 E remove()

Retrieves and removes the head (first element) of this list.
30 E remove(int index)

Removes the element at the specified position in this list.
31 boolean remove(Object o)

Removes the first occurrence of the specified element from this list, if it is present.
32 E removeFirst()

Removes and returns the first element from this list.
33 boolean removeFirstOccurrence(Object o)

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

Removes and returns the last element from this list.
35 boolean removeLastOccurrence(Object o)

Removes the last occurrence of the specified element in this list (when traversing the list from head to tail).
36 E set(int index, E element)

Replaces the element at the specified position in this list with the specified element.
37 int size()

Returns the number of elements in this list.
38 Spliterator<E> spliterator()

Creates a late-binding and fail-fast Spliterator over the elements in this list.
39 Object[] toArray()

Returns an array containing all of the elements in this list in proper sequence (from first to last element).
40 <T> T[] toArray(T[] a)

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

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. Java – ConcurrentMap Interface
  2. Java – AbstractMap Class
  3. Java ArrayList removeIf() method with example
  4. Java – Spliterators.AbstractSpliterator Class
  5. Java – IntConsumer Interface
  6. Java – CompletableFuture Class
  7. Java – BlockingDeque Interface
  8. Java – SynchronousQueue Class
  9. Java – GregorianCalendar Class
  10. Java – CountedCompleter Class
  11. Java – AtomicReferenceArray Class
  12. Java – Callable Interface
  13. Java – IntToDoubleFunction Interface
  14. Java – Stream Interface
  15. Java – Iterator Interface

Be the first to comment

Leave a Reply