June 2017
Beginner
1296 pages
69h 23m
English
... System.out::println
in this case is a method reference—a shorthand notation for a lambda that calls the specified method. A method reference of the form
objectName::instanceMethodName
is a bound instance method reference—“bound” means the specific object to the left of the :: (System.out) must be used to call the instance method to the right of the :: (println). The compiler converts System.out::println into a one-parameter lambda like
x -> System.out.println(x)
that passes the lambda’s argument—the current stream element (represented by x)—to the System.out object’s println instance method, which implicitly outputs the String representation of the argument. The stream pipeline of lines 12–13 is equivalent to the following for loop:
for (int i = 1; i <= 10 ...