An ArrayList never shrinks. The size of an ArrayList does not always refer to the size of the underlying array. Instead it defines the number of accessible elements in that array. When removing an element that is not the last element in the list, the part of the array after the removed element will be shifted to fill the gap. After that the underlying array has one more slot with a null value at the end. The size of the ArrayList will be reduced by one. You can also look at the source code: public E remove(int index) { Objects.checkIndex(index, size); final Object[] es = elementData; @SuppressWarnings("unchecked") E oldValue = (E) es[index]; fastRemove(es, index); return oldValue; } private void fastRemove(Object[] es, int i) { modCount++; final int newSize; if ((newSize = size - 1) > i) System.arraycopy(es, i + 1, es, i, newSize - i); es[size = newSize] = null; } Answer from NautiHooker on reddit.com
W3Schools
w3schools.com › java › ref_arraylist_remove.asp
Java ArrayList remove() Method
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); } }
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 - Java List remove() method is used to remove elements from the list. ArrayList is the most widely used implementation of the List interface, so the examples here will use ArrayList remove() methods.
Videos
09:01
Remove elements from an arraylist in Java - YouTube
Search And Remove From ArrayLists (Java Tutorial)
12:00
remove method in ArrayList - YouTube
#112 Java Remove ArrayList Element
04:19
Searching and removing values from an ArrayList in Java - YouTube
14:01
ArrayList Part 3: Remove (JAVA) - YouTube
TutorialsPoint
tutorialspoint.com › java › util › arraylist_remove.htm
Java ArrayList remove() Method
The Java ArrayList remove(Object) method removes the first occurrence of the specified element from this list, if it is present.If the list does not contain the element, it is unchanged.
Reddit
reddit.com › r/javahelp › how does an arraylist remove an element from an array?
r/javahelp on Reddit: How does an ArrayList remove an element from an array?
March 15, 2023 -
Is it as simple as creating another array and moving all of the elements except the one to be deleted over?
Top answer 1 of 4
12
An ArrayList never shrinks. The size of an ArrayList does not always refer to the size of the underlying array. Instead it defines the number of accessible elements in that array. When removing an element that is not the last element in the list, the part of the array after the removed element will be shifted to fill the gap. After that the underlying array has one more slot with a null value at the end. The size of the ArrayList will be reduced by one. You can also look at the source code: public E remove(int index) { Objects.checkIndex(index, size); final Object[] es = elementData; @SuppressWarnings("unchecked") E oldValue = (E) es[index]; fastRemove(es, index); return oldValue; } private void fastRemove(Object[] es, int i) { modCount++; final int newSize; if ((newSize = size - 1) > i) System.arraycopy(es, i + 1, es, i, newSize - i); es[size = newSize] = null; }
2 of 4
7
A new array isn't created. The remaining elements are moved. One of the great things about open source is you can see for yourself how things are done.
Codecademy
codecademy.com › docs › java › arraylist › .remove()
Java | ArrayList | .remove() | Codecademy
March 21, 2022 - An element can be removed from an ArrayList instance by being passed to the .remove() method.
Programiz
programiz.com › java-programming › library › arraylist › remove
Java ArrayList remove()
In the above example, we have created a arraylist named languages. The arraylist stores the name of programming languages. Here, we have used the remove() method to remove the element Java from the arraylist.
TutorialsPoint
tutorialspoint.com › java › util › arraylist_remove_object.htm
Java.util.ArrayList.remove(Object) Method
The java.util.ArrayList.remove(Object) method removes the first occurrence of the specified element from this list, if it is present.If the list does not contain the element, it is unchanged.
How to do in Java
howtodoinjava.com › home › collections framework › java arraylist › remove element(s) from arraylist in java
Remove Element(s) from ArrayList in Java
August 7, 2023 - The following Java program uses List.removeIf() to remove multiple elements from the arraylist in java by element value.
BeginnersBook
beginnersbook.com › 2013 › 12 › java-arraylist-remove-method-example
Java ArrayList remove(int index) Method example
September 11, 2022 - public Object remove(int index) package beginnersbook.com; import java.util.ArrayList; public class RemoveExample { public static void main(String args[]) { //String ArrayList ArrayList<String> al = new ArrayList<String>(); al.add("AB"); al.add("CD"); al.add("EF"); al.add("GH"); al.add("AB"); al.add("YZ"); System.out.println("ArrayList before remove:"); for(String var: al){ System.out.println(var); } //Removing 1st element al.remove(0); //Removing 3rd element from the remaining list al.remove(2); //Removing 4th element from the remaining list al.remove(2); System.out.println("ArrayList After remove:"); for(String var2: al){ System.out.println(var2); } } } Output: ArrayList before remove: AB CD EF GH AB YZ ArrayList After remove: CD EF YZ ·
GeeksforGeeks
geeksforgeeks.org › java › arraylist-removeall-method-in-java-with-examples
ArrayList removeAll() Method in Java with Examples - GeeksforGeeks
August 6, 2025 - Example 1: Here, we use the removeAll() method to remove all elements from an ArrayList by passing the same list as an argument. ... // Java program to demonstrate removeAll() // by removing all elements from the same ArrayList import ...
Programiz
programiz.com › java-programming › library › arraylist › removeall
Java ArrayList removeAll()
In the above example, we have created an arraylist named numbers and a hashset named primeNumbers. Notice the line, ... Here, the removeAll() method removes all those elements from numbers that are also present in primeNumbers.
W3Schools
w3schools.com › java › ref_arraylist_removeall.asp
Java ArrayList removeAll() Method
The removeAll() method removes all items from a list which belong to a specified collection. ... import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); ...
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.
W3Resource
w3resource.com › java-tutorial › arraylist › arraylist_remove.php
Java arraylist remove Method - w3resource
August 19, 2022 - Java ArrayList.remove(int index) Method with example: The remove() method is used to remove an element at a specified index from ArrayList. Shifts any subsequent elements to the left (subtracts one from their indices).