Java 8 streams, why does this compile part 2… Or what is a method reference, really?
OK, the first question in this "series" was this one . Now, here is another case: Arrays.asList("hello", "world").stream().forEach(System.out::println); This compiles, and works... OK, in the last question, static methods from a class were used. But now this is different: System.out is a static field of System , yes; it is also a PrintStream , and a PrintStream has a println() method which happens to match the signature of a Consumer in this case, and a Consumer is what forEach() expects . So I tried this... public final class Main { public static void main(final String... args) { Arrays