Given an ArrayList and we have to remove some specific record from it in Java.
Here, we are creating an ArrayList and adding 5 elements in it (100, 200, 300, 400 and 500) and further, we are removing 2 elements from index 1 and 3.
To remove an element from ArrayList, we use arrList.remove(index)
Here,
- arrList is an object of "ArrayList" class
- remove is the method of "ArrayList" class, it returns elements from given index.
-
Consider the program
Output