- default methods - it has implementation and can be overridden in implemented classes
- static methods - it has implementation and cannot be overridden in implemented classes
- multiple inheritance
Functional Interface - @FunctionalInterfaces doesn't make interfaces are functional, only if interface has only one method other than default and static methods
- Lambda = (method parameters)->{method definition}
- Method Reference - a shorcut to Lambdas = className::methodName
- Consumer, BiConsumer
- Function, BiFunction, UnaryOperator, BinaryOperator
- Predicate, BiPredicate
- Supplier
- add or remove operations can be done on collections only
- add or remove operations cannot be done on streams students.stream().add students.stream().re
- Collections can get particular object
- Streams cannot get any particular object log.info(students.stream().get);
- Streams are lazy performed - intermediate operations cannot be performed if terminal operations are not performed
- intermediate operations are filters
- terminal operations are collect
- Collections are eagerly construct
- Stream are lazy construct only invoke if terminal operations
- Collections are travers multiple times
- Stream are travers only once
- Collections iterate external
- Stream iterate internal
- studentGradeGreaterThan3Stream.collect(Collectors.toList()).forEach(s->log.info(s.toString()));
- it has been closed or stopped
- map - convert one collections to another collection
- flatMap - convert map into flatMap i.e., Stream<List<String>> into Stream<String> - remove List into single group
- peek - returns the current Stream
- max - return max object by Comparator
- min - return max object by Comparator
- collect - convert stream into collections
- reduce - reduce the stream into single object by BinaryOperator
- allMatch - all objects should match in given stream for given predicate
- anyMatch - any objects should match in given stream for given predicate
- noneMatch - none objects should match in given stream for given predicate
- findAny - return first enumerated object, can also provide sorting
- findFirst - return first object, can also provide sorting
- limit - stream objects have been limited of given number
- skip - rest of stream objects have been skipped of given number
- count - return the objs count in current stream
- sorted - return the objs in sorting order by Comparator in current stream
- distinct - returns stream of distinct objects by Comparator
- filter - filter stream by Predicate
if(boolean1 && boolean2) // boolean2 will not be evaluated if boolean1 is false if(boolean1 || boolean2) // boolean2 will not be evaluated if boolean1 is true in Streams limit(), skip(), findAny(), findFirst(), anyMatch(), allMatch(), noneMatch() are short-circuiting operations these are not operated on each object in the stream
- Stream.of(var args of Objects)
- Stream.iterate(seed,unaryOperator)
- Stream.generate(supplier)
- IntStream - range,rangeClosed,sum,count,min,max,average,asDoubleStream,summaryStatistics,boxed,mapToObj
- LongStream - range,rangeClosed,sum,count,min,max,average,asDoubleStream,summaryStatistics,boxed,mapToObj
- DoubleStream - sum,count,min,max,average,summaryStatistics,boxed,mapToObj
- joining
- counting
- mapping
- maxBy
- minBy
- summingInt, summingLong, summingDouble
- averageInt, averageLong, averageDouble
- groupingBy - classifier | classifier,downstream | classifier,supplier,downstream
- partitionBy
- runs parallel depends on number of processors in the machine
- results vary on mutable objects
- performance is not better for operations on boxed objects
- Of
- OfNullable
- Empty
- get
- orElse
- orElseGet
- orElseThrow
- isPresent
- ifPresent
- LocalDate
- LocalTime
- LocalDateTime
- Period - ComparingDates
- Duration - ComparingTimes
- Instant - DateTime From EPOCH 01-01-1970
- ZonedDateTime | ZoneId | ZoneOffSet
- DateTimeFormatter - parse String to LocalDate|LocalTime|LocalDateTime and format LocalDate|LocalTime|LocalDateTime to String