「Java入門」Listの基本操作(add、remove)方法
Javaコード:
ArrayList <String> list=new ArrayList<>();
list.add(“oosaki");
list.add(“shinagawa");
list.add(“mekuro");
list.add(“iikebukuro");
list.add(“akihabara");
System.out.println(“total:"+list.size()+"element");
list.remove(3);
list.remove(“akihabara");
System.out.println(list.contains(“iikebukuro"));
System.out.println(“index element2:"+list.get(2));
System.out.println(“total"+list.size()+"elements");
//for loop
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
//Iterator
Iterator it = list.iterator();
while(it.hasNext()){
object obj = it.next();
System.out.println(obj);
}