https://github.com/in28minutes/functional-programming-with-java/blob/master/code.md Topics
-
method reference System.out::println
-
stream
-
filter
-
map
-
foreach
-
reduce reduce(0,(x,y)->x+y) 0 is initial val, 2nd param is bi function
-
distinct
-
sorted sort in reverse order by length sorted(Comparator.naturalOrder()) sorted(Comparator.reverseOrder()) sorted(Comparator.comparing(str->str.length()))
courses.stream().sorted((x,y)->y.length()-x.length()).forEach(System.out::println)
-
collect .collect(Collectors.toList());
-
Intermediate operation--steam, map, filter,sorted, distinct
-
Terminal operation -- forEach,reduce
-
collect--specific return type
-
Functional Interface------>
-
Function<T,R>; Predicate; Consumer<T,R>
-
Behaviour Parameterization
-
BinaryOperator--operator: all the params are of the same types, two inputs
and one out put -
Supplier-- no input / but returns
-
UnaryOperator
-
BiPredicate
-
Biunction
-
BiConsumer
-
allmatch, nonematch, anymatch
-
Comparator
-
limit, skip,
-
takewhile---if one element breaks the criteria we will not consider anything after this
-
dropwhile--as long as condition is true we will skip the elements , when we get any element which does not meet the requirement we will consider all the elements including this
-
top, max, min, findFirst, findAny
-
Collect--Collectors--grouping by , maxBy, mapping
-
Stream.of(), Arrays.stream(new int[] {1,2,3})--stream with primitive value
-
IntStream.iterate, IntStream.range()
-
BigInteger
-
flatMap
-
HigherOrder function
-
peek()
-
intermediate operations are lazy--executed on the basis of terminal operation-- execute the work only what is needed
-
Parallel stream
-
removeIf --replaceAll
-
File operations