删除ArrayList指定位置的元素

import java.util.ArrayList;

public class RemoveAnElement {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    ArrayList arrayList = new ArrayList();
        arrayList.add("1");
        arrayList.add("2");
        arrayList.add("3");
       
        Object obj = arrayList.remove(1);
        System.out.println(obj + " is removed from ArrayList");
       
        System.out.println("ArrayList contains...");
        System.out.println(arrayList);
}

}
Console:
2 is removed from ArrayList
ArrayList contains...
[1, 3]

你可能感兴趣的:(删除ArrayList指定位置的元素)