forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
39 lines (32 loc) · 696 Bytes
/
Test.java
File metadata and controls
39 lines (32 loc) · 696 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class Test {
public static void main(String[] args) {
A a = A.mkA(23, 42);
Iterator<Integer> iter = a.getL().iterator();
removeOdd(iter);
}
private static void removeOdd(Iterator<Integer> iter) {
while (iter.hasNext()) {
if (iter.next()%2 != 0)
iter.remove();
}
}
}
class A {
private List<Integer> l;
private A(List<Integer> l) {
this.l = l;
}
public static A mkA(Integer... is) {
return new A(Arrays.asList(is));
}
public static A mkA2(int i) {
return new A(Collections.singletonList(i));
}
public List<Integer> getL() {
return l;
}
}