I am trying to wrap my head around Java 8 concepts. In the context of Method references, I would like to know how does the stream filter method which accepts a 'Predicate predicate' object in my case can also accept a static method in same class. Example below.
public class App
{
public static void main( String[] args )
{
List<Integer> intList = Arrays.asList(1,2,3,4,5);
intList.stream().filter( e -> e > 3 ).forEach(System.out::println);
intList.stream().filter( App::filterNosGrt3 ).forEach(System.out::println);
}
public static boolean filterNosGrt3(Integer no)
{
if(no>3)
return true;
else
return false;
}
}
What confuses me is unlike the Lambda, which is an object in itself, the static method has no object attached to it. So how does it satisfy the filter method here.
Thanks