Java ArrayList.remove(Object o)
Syntax
ArrayList.remove(Object o) has the following syntax.
public boolean remove(Object o)
Example
In the following code shows how to use ArrayList.remove(Object o) method.
//from www . jav a 2s . com
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> arrlist = new ArrayList<String> (5);
arrlist.add("G");
arrlist.add("E");
arrlist.add("F");
arrlist.add("M");
arrlist.add("E");
arrlist.add("from java2s.com");
System.out.println("Size of list: " + arrlist.size());
System.out.println(arrlist);
// Removes first occurrence of "E"
boolean value = arrlist.remove("E");
System.out.println("Now, Size of list: " + arrlist.size());
System.out.println("Value = " + arrlist);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »