/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { ArrayList<Integer> numbers = new ArrayList<>(); numbers.add(10); numbers.add(20); numbers.add(30); numbers.add(40); numbers.add(1, 50); numbers.remove(2); Iterator<Integer> it = numbers.iterator(); while(it.hasNext()){ int value = it.next(); if(value == 30){ it.remove(); } } for(int value : numbers){ } } }
Standard input is empty
add(값) [10, 20, 30, 40] add(인덱스, 값) [10, 50, 20, 30, 40] remove(인덱스) [10, 50, 30, 40] get(인덱스) 30 iterator [10, 50, 40] for each 10 50 40