Java ArrayList.remove(Object o) Method
public boolean remove(Object o)
This method is used to remove the first occurrence of the specified element from this list, if it is present. If the element is not present within the list, it is unchanged.
Package: java.util
Java Platform: Java SE 8
Syntax:
remove(Object o)
Parameters:
Name | Description |
---|---|
o | Element to be removed from this list, if present |
Return Value:
true if this list contained the specified element.
Return Value Type: boolean
Pictorial presentation of ArrayList.remove(Object o) Method

Example: ArrayList.remove(Object o) Method
The following example creates an ArrayList with a capacity of 7 elements ('White' and 'Red 'colors added twice in the list). After adding 7 colors we have removed the first occurrence of "Red" and "White" colors.
Output:
F:\java>javac test.java F:\java>java test ****Color list**** White Black Red White Yellow Red White ****Fresh Color list**** Black White Yellow Red White
Java Code Editor:
Previous:remove(int index) Method
Next:clear Method