VOOZH about

URL: https://www.geeksforgeeks.org/java/linkedlist-remove-method-in-java/

⇱ LinkedList remove() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

LinkedList remove() Method in Java

Last Updated : 11 Jul, 2025

In Java, the remove() method of the LinkedList class removes an element from the list, either by specifying its index or by providing its value.

Example 1: Here, we use the remove() method to remove element from the LinkedList of Strings. By default the remove() will remove the beginning element(head) of the list.


Output
[Geeks, for, Geeks]
[for, Geeks]

Illustration:

👁 remove() LinkedList

Now there are two versions of the remove() method i.e. remove an element by index and remove an element by value.

1. Remove an Element by Index

Syntax:

E remove(int index)

  • Parameter: Index is the position of the element we want to remove from the list.
  • Return Type: This method return the element that was removed from the list.

Example 2: Here, we use the remove() method to remove the element at the specified index from the list.


Output
[A, B, C, D, E]
Removed Element: B
[A, C, D, E]

2. Remove an Element by Value

Syntax:

boolean remove(Object item)

Parameter: item - It is the element we want to delete from the LinkedList.

Return Type: This method will return a boolean value.

  • It will return true, if the specified element is removed form the list
  • It will return false, if the specified element is not found in the list.

Example 3: Here, we use the remove() method to remove any specified element from the LinkedList.


Output
[Geeks, for, Geeks, 10, 20]
[for, Geeks, 10]
Comment