import java util ArrayList import java util Arrays import java util Co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
public class Lists {
public static void main(String[] args) {
test(new Vector<>());
test(Collections.synchronizedList(new ArrayList<>()));
test(new CopyOnWriteArrayList<>());
}
private static void test(List<Integer> list) {
try {
list.addAll(Arrays.asList(1,2,3));
for (Integer i : list) {
list.remove(i);
}
if (list.isEmpty()) {
System.out.println("Массив пустой");
}
} catch (Exception e) {
System.err.println(e);
}
}
}