I have classes like these below:
public class F implements Iterable<P>
{
private final List<P> pra = new ArrayList<P>();
public Iterator<P> iterator()
{
return pra.iterator();
}
public Iterator<P> iterator(S s)
{
return pra.stream().filter(x -> x.s == s).iterator();
}
}
public class P
{
//some code
}
public enum S
{
//some code
}
And i don't know how to call the iterator function in main by foreach loop.
I mean, when the iterator funcion doesn't have an argument, it is simple:
F f = new F();
for(P x: f)
{
System.out.printf("%s\n", p.toString());
}
but how can I do the same, when the iterator function get an argument?