Remove First and Last Elements from LinkedList in Java Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The Java.util.LinkedList.removeFirst() method is used to remove the first element from the LinkedList. The Java.util.LinkedList.removeLast() method is used to remove the last element from the LinkedList. Both the methods also returns the element after removing it. 1. removeFirst() Syntax: LinkedList.removeFirst() Parameters: This function does not take any parameters. Return Value: The method returns the first element or the element present at the head of the list. 2. removeLast() Syntax: LinkedList.removeLast() Parameters: This function does not take any parameters. Return Value: The method returns the last element or the element present at the tail of the list. Example: Java // Java program to illustrate the Java.util.LinkedList.remove() method // and Java.util.LinkedList.removeLast() method import java.util.LinkedList; class GFG { public static void main (String[] args) { // Creating an LinkedList LinkedList<String> list = new LinkedList<String>(); // Use add() method to add elements in the list list.add("Geek"); list.add("for"); list.add("Geeks"); list.add("2020"); list.add("2021"); // Displaying the list System.out.println("LinkedList:\t" + list); // Remove the tail using removeLast() System.out.println("The last element is removed:\t" + list.removeLast()); // Displaying the final list System.out.println("Final LinkedList:\t" + list); // Remove the head using remove() System.out.println("The first element is removed:\t" + list.removeFirst()); // Displaying the final list System.out.println("Final LinkedList:\t" + list); } } OutputLinkedList: [Geek, for, Geeks, 2020, 2021] The last element is removed: 2021 Final LinkedList: [Geek, for, Geeks, 2020] The first element is removed: Geek Final LinkedList: [for, Geeks, 2020] Create Quiz Comment L le0 Follow 0 Improve L le0 Follow 0 Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Collections java-LinkedList +2 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like