What sort of error does it give you? Also, don't use indexOf(foo) just to find the index of the thing you want to delete. Just do remove(foo). Answer from captainAwesomePants on reddit.com
๐ŸŒ
Kotlin
kotlinlang.org โ€บ docs โ€บ whatsnew23.html
What's new in Kotlin 2.3.0 | Kotlin Documentation
4 weeks ago - The new explicit syntax simplifies the common backing properties pattern where a property's internal type is different from its exposed API type. For example, you might use an ArrayList while exposing it as a read-only List or a MutableList.
๐ŸŒ
JavaGoal
javagoal.com โ€บ home โ€บ how to remove element from arraylist java
remove element from ArrayList java and remove(), removeIf() - JavaGoal
July 26, 2020 - Where, Object represents the type of class in ArrayList . obj is the element which you want to remove from the ArrayList . return type: Its return type is boolean. It can return either true or false. If specified obj presents in ArrayList then it returns true after removal of obj otherwise it returns false. import java.util.ArrayList; public class ArrayListExample { public static void main(String[] args) { ArrayList<String> listOfNames = new ArrayList<String>(); listOfNames.add("JAVA"); listOfNames.add("GOAL"); listOfNames.add("Learning"); listOfNames.add("GOAL"); System.out.println("Before re
Discussions

java - How to delete specific element from array list - Stack Overflow
Im trying but its not good. Here is all code: //creating passener object Passenger passenger1 = new Passenger(1, "Stefan", "Jankovic", "stefan@gmail.com", 300... More on stackoverflow.com
๐ŸŒ stackoverflow.com
java - Circular Linked List Implementation - Code Review Stack Exchange
I am currently taking a data structures course at my university right now. I've recently learned about linked lists. Here is my attempt at creating a doubly circular linked list in Java. Is there More on codereview.stackexchange.com
๐ŸŒ codereview.stackexchange.com
2 weeks ago
(Java) Can't remove element from List/ArrayList, always gives NullPointerException or ConcurrentModificationException.
You add every line to the list, but the last line of the file will always return null. You correctly end the loop at that point, but you still add null to the list. That's what is giving those nullpointer exceptions More on reddit.com
๐ŸŒ r/AskProgramming
6
1
October 27, 2019
Java: Need help to remove all instances of objects with a certain field from an arraylist while using a for loop.
What happens to an element at a given index in an arraylist if you remove an entry? What happens when you delete an element, but there's another one that meets the criteria right after the current index? More on reddit.com
๐ŸŒ r/learnprogramming
6
2
October 13, 2021
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ how do i remove an object from an arraylist and delete it in java?
r/learnprogramming on Reddit: How do I remove an object from an arraylist and delete it in java?
March 11, 2021 -

So, basically I want to do a shopping list that you can put the price, quantity, name. I want to implement a button that deletes an object. I have tried doing "int s = objectList.indexOf(myobject); objectList.remove(s); myobject=null;", but it keeps giving me errors. Please help me, if you need any code from my project, I will give it. Btw, the object extends JPanel

๐ŸŒ
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
For example, a call to remove("two") will remove the second element from ArrayList. Though you should remember to use the Iterator or ListIterator remove() method to delete elements while iterating, using ArrayList's remove methods, in that case, will throw ConcurrentModificationException in Java.
๐ŸŒ
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); } }
๐ŸŒ
Quora
quora.com โ€บ What-does-the-remove-of-the-arraylist-element-mean
What does the remove of the arraylist element mean? - Quora
Answer (1 of 2): Yep, when an item is removed from an ArrayList, all items after it will move forward to fill the space. If you remove element four (which is what list.remove(4); does), all the items after item number 5 (lists are zero indexed) ...
Find elsewhere
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 627559 โ€บ java โ€บ remove-item-Arraylist-looping
How to remove a item from Arraylist without looping it (Java in General forum at Coderanch)
January 25, 2014 - i have a Array-list which contain list of names.I need to remove one name.I can do this using for loop and find the index of element and delete it.But i need to delete it without looping.Is there any method to delete element by name? or can i use any other Data Structure in Java for this issue? ... You don't need to loop. There's already an API http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#remove(java.lang.Object) ... Thanks Jaikiran. ... sam liyanage wrote:But i need to delete it without looping. I don't know where that requirement came from; let me point out that the ArrayList.remove(Object) very likely uses looping to achieve its goal.
๐ŸŒ
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. ArrayList class provides two overloaded remove() methods. remove(int index): Accepts the index of the object to be removed ยท remove(Object obj): Accepts the object to be removed ยท Let us figure out with the help of examples been provided below as follows: ... // Java program to Remove Elements from ArrayList // Using remove() method by indices // Importing required classe
๐ŸŒ
coderolls
coderolls.com โ€บ remove-element-from-arraylist
How To Remove An Element From An ArrayList? - Coderolls
December 2, 2021 - remove(Object o) - we can remove the specified object from the ArrayList ยท remove(int index) - We can remove an element at the position (index) specified ยท The example Java programs given in the above tutorial can be found at this GitHub Repository.
๐ŸŒ
CODEDOST
codedost.com โ€บ home โ€บ java โ€บ collections in java โ€บ remove element from a specific index in arraylist in java
Remove element from a specific index in ArrayList in JAVA | CODEDOST
July 27, 2021 - Let's see a small program, which will remove the element from a particular index in the ArrayList. import java.util.ArrayList; class Main { public static void main(String args[]) { ArrayList<Integer> al = new ArrayList<Integer>(); //Inserting elements in al al.add(100); al.add(200); al.add(300); al.add(400); System.out.println("Elements in ArrayList"); for(int num: al) System.out.println(num + " "); //remove element from index 3 i.e.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ remove-all-occurrences-of-an-element-from-array-in-java
Remove all Occurrences of an Element from Array in Java - GeeksforGeeks
July 11, 2025 - Illustration: Using the ArrayList to remove all occurrences of an element from an array. ... // Java program remove all occurrences // of an element from Array using ArrayList import java.util.ArrayList; import java.util.Arrays; import java.util.List; // Driver Class public class Geeks { // Main Method public static void main(String[] args) { Integer[] a = { 3, 9, 2, 3, 1, 7, 2, 3, 5 }; // Element to be removed Integer k = 3; // Convert array to ArrayList List<Integer> l = new ArrayList<>(Arrays.asList(a)); // Remove all occurrences of the element l.removeAll(Arrays.asList(k)); // Convert ArrayList back to array Integer[] newArr = l.toArray(new Integer[0]); // Print the result System.out.println(Arrays.toString(newArr)); } }
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ java-remove-array-elements
How to Remove Array Elements in Java | DigitalOcean
May 2, 2025 - In this tutorial, we explored various methods for removing elements from arrays in Java, including using for loops, System.arraycopy(), and converting to an ArrayList. We also highlighted the advantages of using ArrayLists for frequent element deletion or addition due to their dynamic nature and built-in functions.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java collections โ€บ removing elements from java collections
Removing Elements from Java Collections | Baeldung
January 8, 2024 - Collection<String> names = new ArrayList<>(); names.add("John"); names.add("Ana"); names.add("Mary"); names.add("Anthony"); names.add("Mark"); Javaโ€™s Iterator enables us to both walk and remove every individual element within a Collection.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_arraylist_removeall.asp
Java ArrayList removeAll() Method
import java.util.ArrayList; public ... cars.removeAll(cars); System.out.println(cars); } } ... The removeAll() method removes all items from a list which belong to a specified collection....
๐ŸŒ
CodeChef
codechef.com โ€บ practice โ€บ arrays
Practice Arrays
Solve Arrays coding problems to start learning data structures and algorithms. This curated set of 23 standard Arrays questions will give you the confidence to solve interview questions.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ java/util โ€บ java arraylist remove object
Java ArrayList Remove Object
September 1, 2008 - 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.
๐ŸŒ
Vultr
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ util โ€บ ArrayList โ€บ removeIf
Java ArrayList removeIf() - Filter Elements Conditionally | Vultr Docs
November 13, 2024 - The removeIf() method in Java's ArrayList class offers a straightforward way to remove elements from a list based on a condition specified via a lambda expression or predicate.