import java.util.ArrayList.Output:
public class removeArrayListIndex{
public static void main(String[] args) {
// ArrayList を作成します<文字列>
ArrayList<文字列>aList = new ArrayListです<文字列>();
//ArrayListに文字列を追加
aList.add("1");
aList.add("2");
aList.add("3");
aList.add("4");
aList.add("5");
System.out.println("削除前のArrayList:");
for(String e:aList)
System.out.println(e);
//1
にあるオブジェクトを削除します aList.remove(1);
System.out.println("削除後のArrayList:");
for(String e:aList)
System.out.println(e);
//3
aList.remove(3);
System.out.println("削除後のArrayList:");
for(String e:aList)
System.out.println(e);
}
}
削除前のArrayList: 削除後の
1
2
3
4
5
ArrayList:
1
3
4
5
ArrayList削除後:
1
3
4
Please disable your ad blocker and refresh the window to use this website.