Skip to main content

Posts

Showing posts with the label Java 8

Java 8 : Streams at Go:

JAVA 8                          STREAM INTSTREAM LONGSTREAM DOUBLESTREAM OF Stream. Of (array) Stream. of ( "str1" , "str2" ) LIMIT OPERATION Stream. Generate () Stream. iterate () DISTINCT OPERATION (list/set). stream . distinct (). foreach (x- ' > ' t;ysout(x);) (list/set). stream . distinct (). collect (toSet()); (list/set). stream . distinct (). collect (toList()); CONCAT OPERATION Stream. concat (l1. stream (), l2. stream ()). collect (Collectors. toList ()); FOREACH OPERATION (list/set). stream . distinct (). foreach () COUNT OPERATION (list/set). stream . count () (list/set). stream . distinct (). count () MATCH OPERATION (list/set). stream .(anyMatch()|allMatch()|noneMatch()) (list/set). stream . count () (list/set). stream . distinct (). count () (list/set). stream .(anyMatch()|allMatch()|noneMatch()) FIND OPERATION (list/set). stream . findAny () (list/set). stream . findAll () list. strea...

Java 8 Collectors at a Go

package collectors ; import java.util.List ; import java.util.Map ; import java.util.stream.Collectors ; public class CollectorsExamples { public static void main ( String args []){ List < Employee > employeeList = Employee . getEmployeesSalary () ; totalAgeOfEmployees ( employeeList ) ; getMinAgeEmployees ( employeeList ) ; getMaxAgeEmployees ( employeeList ) ; getNamesInUpperCase ( employeeList ) ; createEmployeeMap ( employeeList ) ; createEmployeeNameString ( employeeList ) ; createEmployeeMap2 ( employeeList ) ; partitioningByExample ( employeeList ) ; groupinggByExample ( employeeList ) ; groupinggByExample ( employeeList ) ; grouping_mapping_By_Example ( employeeList ) ; grouping_mapping_collectingAndThen_By_Example ( employeeList ) ; countNames ( employeeList ) ; grouping_counting_By_Example ( employeeList ) ; grouping_counting_By...

Java 8 : Conversions

- -

Java 8 :Terminal operation sum, reduce, count, : map, array, Intermediate operations : filter,distinct,concat

-- --

JAVA 8 :Quick Look

Iteration on example https://tvidushi.blogspot.com/2017/12/java-8-iteration.html java 8 at a go https://tvidushi.blogspot.com/2017/12/java-8-at-go.html COMPARATOR EXAMPLES https://tvidushi.blogspot.com/2017/12/java-8-comparator-examples.html JAVA 8 : FINDING ALLMATCH, NONEMATCH,ANYMATCH https://tvidushi.blogspot.com/2017/12/java-8-finding-matches.html Interfaces  https://tvidushi.blogspot.com/2017/12/java-8-fi-biconsumer-bifunction.html JAVA 8 : FIND ANY , FIRST ,MAX, MIN ,FIRST FEW(LIMIT) ,(FIRST FEW FROM MULTIPLE LISTS) . https://tvidushi.blogspot.com/2017/12/java-8-common-operations.html JAVA 8:DATE TIME API https://tvidushi.blogspot.com/2017/12/java-8lamda.html

Comparator Examples

Comparator Example : Sort By Frequency Sorting By Comparators in java 8 -- -- --

Java 8: FI BIConsumer, BiFunction, BiPredicate, Predicate, Supplier

 In progress Interface Description BiConsumer It represents an operation that accepts two input arguments and returns no result. Consumer It represents an operation that accepts a single argument and returns no result. Function It represents a function that accepts one argument and returns a result. Predicate It represents a predicate (boolean-valued function) of one argument. BiFunction It represents a function that accepts two arguments and returns a a result. BinaryOperator It represents an operation upon two operands of the same data type. It returns a result of the same type as the operands. BiPredicate It represents a predicate (boolean-valued function) of two arguments. BooleanSupplier It represents a supplier of boolean-valued results. DoubleBinaryOperator It represents an operation upon two double type operands and returns a double type value. DoubleConsumer It represents an operation that accepts a single double type argument and returns no result. ...

Java 8 :Collectors

JAVA 8 :COLLECTORS AVERAGING public static Collector averagingInt(ToIntFunction mapper) Double avgAge = residents .stream() .collect(Collectors.averagingInt(Person::getAge)); } public static Collector averagingLong(ToLongFunction mapper) Double avgAge = residents .stream() .collect(Collectors.averagingLong(Person::getAge)); } public static Collector averagingDouble(ToDoubleFunction mapper) Double avgAge = residents .stream() .collect(Collectors.averagingDouble(Person::getAge)); } GROUPING Map employeeMap = employeeList.stream().collect(Collectors.groupingBy(Employee::getDepartment)); GROUPING BY SPECIFYING COLLECTOR Map employeeMap = employeeList.stream() .collect(Collectors.groupingBy(Employee::getDepartment, Collectors.toSet())); PARTITIONING  BY PREDICATE Map employeeMap = employeeList .stream() .collect(Collectors.partitioningBy((Employee ...

java 8 Reference

--> This page will cover java 8 tutorials with examples. Lambda expressions are one of the important features included in java 8. Lambda Expressions are used to write concise code. Java 8 has introduced stream API that supports functional-style operations on streams of elements. Java 8 streams can be computed in parallel and sequential way. Sequential computation is performed one by one in an order. In parallel processing computations are processed simultaneously. There is many other new API such as time, collectors, completable future etc. Now find java 8 examples one by one. Java 8 Concat Streams, Lists, Sets, Arrays Example On this page we will provide Java 8 concat Streams, Lists, Sets, Arrays example.  Stream  provides  concat() method to concatenate two streams and will return a stream. Java 8 Distinct Example On this page we will provide Java 8 Stream  distinct()  example.  distinct()  returns a stre...