March 2019
Intermediate to advanced
242 pages
6h 21m
English
When you write a lambda expression, you can define multiple parameters. The following are some examples of lambdas that define single or multiple parameters:
key -> key.uppercase(); // single lambda parameter (int x, int y) -> x > y? x : y; // two lambda parameters (a, b, c, d) -> a + b + c + d; // four lambda parameters
Let's use one of the lambdas from the preceding code in stream processing. The following example will provide the string values from List as output, in uppercase:
List<String> talks = List.of("Kubernetes", "Docker", "Java 11");talks.stream() .map(key -> key.toUpperCase()) .forEach(System.out::prinltn);
So far, so good. But what happens if the preceding code is defined in a method (say, ...
Read now
Unlock full access