About Question enthuware.ocpjp.i.v11.2.1469 :
Posted: Tue Jun 23, 2020 5:10 pm
As written I did not managed to answer to this question.
I think :
1- the filterData should be declared static or a Data Object should be instantied.
2- the al Arraylist should be instantied too.
I rewrote the code like this:
I think :
1- the filterData should be declared static or a Data Object should be instantied.
2- the al Arraylist should be instantied too.
I rewrote the code like this:
Code: Select all
static void filterData(ArrayList<Data> dataList, Predicate<Data> p){
Iterator<Data> i = dataList.iterator();
while (i.hasNext()){
if (p.test(i.next())){
i.remove();
}
}
}
...........
ArrayList<Data> al = new ArrayList<>();
Data d;
d = new Data(1); al.add(d);
d = new Data(2); al.add(d);
d = new Data(3); al.add(d);
//INSERT METHOD CALL HERE
System.out.println(al);