'Fixed formatting;'

This commit is contained in:
Arkadiusz Hypki 2024-05-20 17:49:51 +02:00
parent 96a395a6e3
commit 044990ab6c
2 changed files with 11 additions and 8 deletions

View File

@ -27,7 +27,7 @@ public class FunctionChaining {
multiply
.andThen(add)
.andThen(logOutput)
.apply(input);
.apply(input);
}
public static void main(String[] args) {

View File

@ -18,7 +18,8 @@ public class Parallel {
// map
System.out.println("Computing squares (with limit and sort): ");
List<Integer> numbers = Arrays.asList(2,3,4,5);
numbers.stream()
numbers
.stream()
.map(x -> x *x) // Function
.sorted()
.limit(2)
@ -33,15 +34,16 @@ public class Parallel {
.stream()
.filter(s -> s.startsWith("S")) // Predicate
.collect(Collectors.toList())
.forEach(System.out::println);;
.forEach(System.out::println);
// print output -> [Sally, Sephora]
// sorted
System.out.println("Sorting names: ");
names.stream()
names
.stream()
.sorted()
.collect(Collectors.toList())
.forEach(System.out::println);;
.forEach(System.out::println);
// print output -> [Harry, Sally, Sephora]
// reduce
@ -79,16 +81,17 @@ public class Parallel {
.stream()
.skip(1)
.collect(Collectors.toList())
.forEach(System.out::println);;
.forEach(System.out::println);
// print output -> [3,4,5]
System.out.println("Computing squares in parallel: ");
numbers.stream()
numbers
.stream()
.parallel() // add this line here
.map(x -> x *x)
.sorted()
.limit(2)
.collect(Collectors.toList())
.forEach(System.out::println);;
.forEach(System.out::println);
}
}