Here's the method I'm trying to write ( doesn't compile now, because what
is not seen as an Iterable ):
public <T,V> ArrayList<V> mySelect(T what,ITest<V> x) {
ArrayList<V> results = new ArrayList<V>();
for(V value : what) {
if(x.accept(value)) {
results.add(value);
}
}
return results;
}
The T
type implements Iterable
, and returns V
objects when using foreach
. The thing is, I don't know how to write that. Can you help?