See the documentation for ArrayList#remove(int), as in the following syntax:

list.remove(list.size() - 1)

Here is how it's implemented. elementData does a lookup on the backing array (so it can cut it loose from the array), which should be constant time (since the JVM knows the size of an object reference and the number of entries it can calculate the offset), and numMoved is 0 for this case:

public E remove(int index) {
    rangeCheck(index); // throws an exception if out of bounds

    modCount++;        // each time a structural change happens
                       // used for ConcurrentModificationExceptions

    E oldValue = elementData(index);

    int numMoved = size - index - 1;
    if (numMoved > 0)
        System.arraycopy(elementData, index+1, elementData, index,
                         numMoved);
    elementData[--size] = null; // Let gc do its work

    return oldValue;
}
Answer from Nathan Hughes on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › removing-last-element-from-arraylist-in-java
Removing last element from ArrayList in Java - GeeksforGeeks
July 12, 2025 - We can use the remove() method of ArrayList container in Java to remove the last element.
🌐
GeeksforGeeks
geeksforgeeks.org › java › linkedlist-removelast-method-in-java
LinkedList removeLast() Method in Java - GeeksforGeeks
July 11, 2025 - In Java, the removeLast() method of LinkedList class is used to remove and return the last element of the list.
🌐
Quora
quora.com › How-do-you-remove-the-first-and-last-elements-from-a-Java-List
How to remove the first and last elements from a Java List - Quora
Answer (1 of 2): You’re not specifying the list type to be used. The most efficient way to remove the head and tail nodes of a list depends on the concrete list. The general solution (ignoring bound checks for now) is to do the following: [code]List list = ...; list.remove(0); list.remov...
🌐
Java Guides
javaguides.net › 2024 › 06 › java-arraylist-removelast-method.html
Java ArrayList removeLast() Method
June 11, 2024 - The removeLast() method is part of the ArrayList class in Java 21. It allows you to remove the last element of the list directly, simplifying the process of removing the last element without needing to handle the index manually.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › java › util › linkedlist_removelast.htm
Java LinkedList removeLast() Method
The Java LinkedList removeLast() method retrieves and removes the last element of this linkedList.
🌐
Xenovation
xenovation.com › home › blog › java › how to remove the last element from list in java?
How to remove the last element from List in Java? (ArrayList, LinkedList, Vector)
June 24, 2020 - import java.util.ArrayList; import java.util.List; public class RemoveLastElementFromList { public static void main(String[] args) { List lList = new ArrayList<>(); RemoveLastElementFromList lMyClass = new RemoveLastElementFromList(); lMyClass.addTestData(lList); lMyClass.removeLastElement(lList); } public void removeLastElement(List<?> pList) { // get the index of the last entry from the list int lLastIndex = -1; if (pList.isEmpty()) { // nothing to remove } else { lLastIndex = pList.size() - 1; // if you do not need the last element anymore pList.remove(lLastIndex); } } public void addTestData(List pList) { pList.add("first"); pList.add("second"); pList.add("third"); pList.add("fourth"); } } You do not care what the last element is.
🌐
Techie Delight
techiedelight.com › home › java › remove last element from a list in java
Remove last element from a List in Java | Techie Delight
July 7, 2026 - In this quick article, we’ll see how to remove the last element of a list in Java.. We can use the `remove()` method of the `List` interface, which removes an element at the specified position in the list.
🌐
Educative
educative.io › answers › what-is-the-linkedlistremovelast-method-in-java
What is the LinkedList.removeLast() method in Java?
From lines 5 to 7, we use the add() method of the list object to add three elements ("1","2","3") to the list. ... In line 10, we use the removeLast() method of the list object to remove and return the last element of the list.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › List.html
List (Java SE 21 & JDK 21)
January 20, 2026 - Removes from this list all of its elements that are contained in the specified collection (optional operation). default E · removeFirst() Removes and returns the first element of this collection (optional operation). default E · removeLast() Removes and returns the last element of this collection ...
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
BeginnersBook
beginnersbook.com › 2014 › 07 › java-remove-first-and-last-element-from-linkedlist-example
Java – Remove first and last element from LinkedList example
September 11, 2022 - 2) public E removeLast(): Removes and returns the last element from this list. ... import java.util.LinkedList; public class RemoveExample { public static void main(String[] args) { // Create a LinkedList LinkedList<String> linkedlist = new LinkedList<String>(); // Add elements to LinkedList ...
🌐
GitHub
github.com › jumpalottahigh › JavaChallenge-MOOC-course › blob › master › week3-062.RemoveLast › src › RemoveLast.java
JavaChallenge-MOOC-course/week3-062.RemoveLast/src/RemoveLast.java at master · jumpalottahigh/JavaChallenge-MOOC-course
import java.util.Collections; · public class RemoveLast { public static void removeLast(ArrayList<String> list) { int i = list.size(); list.remove(i-1); } · public static void main(String[] args) { // Here an example what you can do with the method ·
Author: jumpalottahigh