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:
|
import java.util.*;
public class Test{
public static class Testing{
private int id;
public Testing(int id){
this.id = id;
}
public int getID(){
return id;
}
}
private static ArrayList<Testing> nodes = new ArrayList<>();
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
Testing t1 = new Testing(1);
Testing t2 = new Testing(2);
nodes.add(t1);
nodes.add(t2);
Iterator<Testing> i = nodes.iterator();
while(i.hasNext()){
if (i.next().getID() == 2)
System.out.println(i.next());
}
}
} |