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 - ArrayList provides two overloaded remove() method: remove(int index) : Accept index of the object to be removed. We can pass the last elements index to the remove() method to delete the last element.
🌐
Java Guides
javaguides.net › 2024 › 06 › java-arraylist-removelast-method.html
Java ArrayList removeLast() Method
June 11, 2024 - The removeLast method can be used to remove the last element of the ArrayList. import java.util.ArrayList; import java.util.List; public class RemoveLastExample { public static void main(String[] args) { List<String> list = new ArrayList<>(); ...
🌐
W3Schools
w3schools.com › java › ref_arraylist_remove.asp
Java ArrayList remove() Method
If a value is specified and multiple elements in the list have the same value then only the first one is deleted. If the list contains integers and you want to delete an integer based on its value you will need to pass an Integer object. See More Examples below for an example. ... T refers to the data type of items in the list. Remove an integer from the list by position and by value: import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); list.add(5); list.add(8); list.add(9); list.add(1); list.remove(Integer.valueOf(1)); // Remove by object list.remove(1); // Remove by index System.out.println(list); } }
🌐
Baeldung
baeldung.com › home › java › java list › removing an element from an arraylist
Removing an Element From an ArrayList | Baeldung
April 4, 2025 - As we can see, removeLast() is pretty straightforward to use and easier to understand. Therefore, if we’re using JDK 21 or higher, this method can be a good option for removing the last element from a List. Sometimes, we want to remove an element from an ArrayList while we’re looping it.
🌐
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 - The fastest way is to use the remove(pList.size()-1) of the List interface to remove the last entry. import java.util.ArrayList; import java.util.List; public class RemoveLastElementFromList { public static void main(String[] args) { List lList ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › remove-element-arraylist-java
How to remove an element from ArrayList in Java? - GeeksforGeeks
July 23, 2025 - It is a default method as soon as we do use any method over data structure it is basically operating over indexes only so whenever we do use remove() method we are basically removing elements from indices from an ArrayList.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-list-remove-methods-arraylist-remove
How To Use remove() Methods for Java List and ArrayList | DigitalOcean
September 9, 2025 - This method returns true if an element is removed from the list, otherwise false. If the object is null and list doesn’t support null elements, NullPointerException is thrown. UnsupportedOperationException is thrown if the list implementation doesn’t support this method. Let’s look into some examples of remove() methods. ... List<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); list.add("C"); list.add("B"); list.add("A"); System.out.println(list); String removedStr = list.remove(1); System.out.println(list); System.out.println(removedStr);
🌐
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...
Find elsewhere
🌐
Reactgo
reactgo.com › home › how to remove the last element of an arraylist in java
How to remove the last element of an ArrayList in Java | Reactgo
December 24, 2022 - ... To remove the last element of a ArrayList, we can use the list.remove() method by passing its index list.size()-1 as an argument to it. The list.size()-1 gives the index of an last element.
🌐
CodeGym
codegym.cc › java blog › java collections › how to remove an element from arraylist in java?
How to remove an element from ArrayList in Java | CodeGym
December 10, 2024 - The iterator is smarter than it may appear: remove() removes the last element returned by the iterator. As you can see, it did just what we wanted it to do :) In principle, this is everything you need to know about removing elements from an ...
🌐
TutorialsPoint
tutorialspoint.com › home › java/util › java arraydeque removelast method
Java ArrayDeque removeLast Method
September 1, 2008 - The Java ArrayDeque removeLast() method retrieves and removes the last element of this deque.
🌐
Java67
java67.com › 2015 › 06 › how-to-remove-elements-from-arraylist.html
How to Delete Objects from ArrayList in Java? ArrayList.remove() method Example | Java67
This is different than the size of array which is backing ArrayList, which will remain same. In our example, you can see that number of elements is gradually reduced after removal. By using index you can easily remove the first or last element ...
🌐
TutorialKart
tutorialkart.com › java › java-remove-last-element-of-array
Remove Last Element of Array in Java
October 16, 2021 - To remove the last element of an Array in Java, call Arrays.copyOf() method and pass the array and new size as arguments. The new size must be one less than the size of original array.
🌐
Quora
quora.com › How-can-I-delete-the-last-n-elements-from-an-array-in-Java
How to delete the last n elements from an array in Java - Quora
You can * create a new, smaller array (having a size of the original array minus n) and use System.arraycopy(…) to copy the elements you want to keep over from the old to the new array - this is most likely the best option, unless your arrays ...