In your case, there's no need to iterate through the list, because you know which object to delete. You have several options. First you can remove the object by index (so if you know, that the object is the second list element):

 a.remove(1);       // indexes are zero-based

Or, you can remove the first occurence of your string:

 a.remove("acbd");  // removes the first String object that is equal to the
                    // String represented by this literal

Or, remove all strings with a certain value:

 while(a.remove("acbd")) {}

It's a bit more complicated, if you have more complex objects in your collection and want to remove instances, that have a certain property. So that you can't remove them by using remove with an object that is equal to the one you want to delete.

In those case, I usually use a second list to collect all instances that I want to delete and remove them in a second pass:

 List<MyBean> deleteCandidates = new ArrayList<>();
 List<MyBean> myBeans = getThemFromSomewhere();

 // Pass 1 - collect delete candidates
 for (MyBean myBean : myBeans) {
    if (shallBeDeleted(myBean)) {
       deleteCandidates.add(myBean);
    }
 }

 // Pass 2 - delete
 for (MyBean deleteCandidate : deleteCandidates) {
    myBeans.remove(deleteCandidate);
 }
Answer from Andreas Dolk on Stack Overflow
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › java › remove-element-arraylist-java
How to remove an element from ArrayList in Java? - GeeksforGeeks
July 23, 2025 - Methods: There are 3 ways to remove an element from ArrayList as listed which later on will be revealed as follows: Using remove() method by indexes(default) Using remove() method by values ·
Discussions

java - How to remove element from ArrayList by checking its value? - Stack Overflow
I know we can iterate over arraylist, and .remove() method to remove element but I dont know how to do it while iterating. How can I remove element which has value "acbd", that is second element? ... Anders R. Bystrup – Anders R. More on stackoverflow.com
🌐 stackoverflow.com
Question and solution: How to delete or add an object to/from array list while iterating it.
Hi few days ago i was encountered a problem. While iterating an array list by a for each loop, i was trying to remove the current object in spesific… More on reddit.com
🌐 r/processing
7
9
December 28, 2022
How does an ArrayList remove an element from an array?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
6
10
March 15, 2023
Why is the add(index, element) time complexity not constant in Java for array lists?

For array lists, you would have to move all elements to adjacent positions when you insert at an index. So it takes linear time ( more the number of elements already in the list, more time it takes to move them all ).

Also Java has nothing to do with time complexities of a data structure. It is universal.

More on reddit.com
🌐 r/learnjava
8
2
June 1, 2020
🌐
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 - ArrayList<String> arraylist2 = new ArrayList<>(); //1 - Remove an element from the specified index position arraylist.remove(indexPosition); //2 - Remove the first occurence of element by its value arraylist.remove(element); //3 - Remove all elements of the specified collection from arraylist arraylist.removeAll(Arrays.asList(ele1, ele2, ele3)); //4 - Remove all elements matching a condition arraylist.removeIf(e -> e.contains("temp"));
🌐
Codecademy
codecademy.com › docs › java › arraylist › .remove()
Java | ArrayList | .remove() | Codecademy
March 21, 2022 - Beginner Friendly.Beginner Friendly17 hours17 hours · An element can be removed from an ArrayList instance by being passed to the .remove() method. It can be referenced either by value ...
🌐
Vultr
docs.vultr.com › java › standard-library › java › util › ArrayList › remove
Java ArrayList remove() - Delete Element | Vultr Docs
November 14, 2024 - The remove() method in Java's ArrayList class is a versatile tool used to delete elements from an array list. Whether you need to remove a specific element by value or an element at a particular index, this method provides a straightforward approach.
🌐
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 - You can use the remove() method to achieve this. Here’s an example: List<Post> posts = new ArrayList<>(); // Assuming posts is populated with user posts // Remove all posts from a banned user String bannedUserId = "bannedUser123"; posts.removeIf(post -> post.getUserId().equals(bannedUserId));
Find elsewhere
🌐
How to do in Java
howtodoinjava.com › home › collections framework › java arraylist › java arraylist remove(): remove a single element from list
Java ArrayList remove(): Remove a Single Element from List with Examples - HowToDoInJava
August 7, 2023 - If the list does not contain the element, the list remains unchanged. The remove() method is overloaded and comes in two forms: boolean remove(Object o) – removes the first occurrence of the specified element by value from the list.
🌐
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 ArrayList. Well, almost everything. In the next lesson, we'll look inside this class, and see what happens there during various method calls :) Until then! ... Volodymyr is one of those who learned Java development thanks to the CodeGym course, and after studying, got a job in our company.
🌐
Programiz
programiz.com › java-programming › library › arraylist › remove
Java ArrayList remove()
Integer.valueOf() - Converts the int value 13 to an Integer object. It is because the remove() method only takes objects as its arguments. To learn more, visit Java Primitive Types to Wrapper Objects. remove() - Removes the element 13 that appeared first in the arraylist.
🌐
Reddit
reddit.com › r/processing › question and solution: how to delete or add an object to/from array list while iterating it.
r/processing on Reddit: Question and solution: How to delete or add an object to/from array list while iterating it.
December 28, 2022 - See also the retainAll and removeAll methods in the JavaDoc. Another option is to create a new ArrayList containing all the elements you want to remove, and after the loop completes call mylist.removeAll(toRemove) (or, if you're discarding most of the list, reverse that and use mylist.retainAll(toKeep).
🌐
TutorialsPoint
tutorialspoint.com › how-to-remove-element-from-arraylist-in-java
How to remove element from ArrayList in Java?
June 23, 2020 - The example below uses the remove() method inside the for-loop to remove each element one by one on every iteration from the ArrayList {10, 20, 30, 40}: import java.util.ArrayList; public class removeElement { public static void main(String[] args) { //creating an ArrayList ArrayList<Integer> ...
🌐
Javaprogramto
javaprogramto.com › 2019 › 04 › how-to-remove-element-from-arraylist.html
How to remove an element from ArrayList in Java? JavaProgramTo.com
August 4, 2019 - We can remove the elements from ArrayList using index or its value using following methods of ArrayList. 1) remove(int index): Takes the index of the element 2) remove(Object o): Takes actual value present in the arraylist.
🌐
Java67
java67.com › 2014 › 03 › 2-ways-to-remove-elementsobjects-from-ArrayList-java.html
2 Ways to Remove Elements/Objects From ArrayList in Java [Example] | Java67
System.out.println("ArrayList Before : " + numbers); // Calling remove(index) numbers.remove(1); //removing object at index 1 i.e. 2nd Object, which is 2 //Calling remove(object) numbers.remove(new Integer(3)); System.out.println("ArrayList After : " + numbers); Output : ArrayList Before : [1, 2, 3] ArrayList After : [1] This time, it works, but I am afraid of lazy developers like me, which take autoboxing for granted. Now let's take a look at removing the object from ArrayList while Iterating over them. You must be familiar with Iterator in Java, before proceeding further.
🌐
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
There are actually two methods to remove an existing element from ArrayList, first by using the remove(int index) method, which removes elements with a given index, remember the index starts with zero in ArrayList.
🌐
Baeldung
baeldung.com › home › java › java list › remove all occurrences of a specific value from a list
Remove All Occurrences of a Specific Value from a List | Baeldung
June 27, 2025 - In Java, it’s straightforward to remove a specific value from a List using List.remove(). However, efficiently removing all occurrences of a value is much harder. In this tutorial, we’ll see multiple solutions to this problem, describing the pros and cons. For the sake of readability, we use a custom list(int…) method in the tests, which returns an ArrayList containing the elements we passed.
🌐
TutorialsPoint
tutorialspoint.com › java › util › arraylist_remove.htm
Java ArrayList remove() Method
The following example shows the usage of Java ArrayList remove(index) method. We're creating a ArrayList of Student objects. We're adding couple of Students to the ArrayList object using add() method calls per element.
🌐
TutorialsPoint
tutorialspoint.com › java › util › arraylist_remove_object.htm
Java.util.ArrayList.remove(Object) Method
... The following example shows the usage of java.util.ArrayList.remove(object) method. package com.tutorialspoint; import java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { // create an empty array list ...
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-arraylist-remove-method-example
Java ArrayList remove(int index) Method example
September 11, 2022 - Method remove(int index) is used for removing an element of the specified index from a list. It removes an element and returns the same. It throws IndexOutOfBoundsException if the specified index is less than zero or greater than the size of the list (index size of ArrayList).