Remove an element from specified index of ArrayList in Java
Description
The following code shows how to remove an element from specified index of ArrayList.
Example
/*from ww w .j ava 2s. c om*/
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("1");
arrayList.add("2");
arrayList.add("java2s.com");
Object obj = arrayList.remove(1);
System.out.println(obj + " is removed from ArrayList");
for (String str: arrayList)
System.out.println(str);
}
}
The code above generates the following result.