2. About Me
• Java Developer
• Technical Teacher
• Blogger @kodcu.com
3. Java 8 Innovations
• Lambda Expressions
• Type Inference
• Metod References
• Collection II
• Defender Methods
4. Functional Interface ?
• An Interface includes only one abstract
method called as FunctionalInterface
• Lambda expressions are converted to a FI’s
implementation in Background
6. Lambda Expressions
• Lambda -> (also called Closures), is an expression
that reduces vertical boilerplate code.
• Concise and Clear code development practice
• Interfaces that consist of one more than abstract
method, cannot be counterpart of any Lambda
expressions.
Tip: Exceptions (Defender methods & Object class’ methods)
14. Collection II
• Collection II is an attachment to existing
Collection Framework.
• Supports Jquery like chained methods and
Underscore.js like Functional Programming
Experience.
15. Collection II
• Existing Collection Framework does not
support Concurrent operations in
chunked datas.
• Cause, existing one applies External
Iteration.
16. Stream <T> Interface
• Sequential and Consumable data structure.
• The data cannot be fetch again after consumed.
• A Stream object can be obtained any data
structure in Collection Framework.
• Fo.Exm: LinkedList, ArrayList, HashSet.
17. java.util.function
Functional Interfaces
• Those special Interfaces
support general data
operations.
18. Consumer<T> -> Applying
• Consumer gets an input and runs an action.
• Does not return any result, only do an action.
public void accept(T t);
19. Predicate<T> -> Filtering
• Predicate gets a conditional code and
produce -> true || false
• In concise, makes filtering.
public boolean test(T t);
20. Function<T, R> -> (Consume & Produce);
• Gets any type of input object and Produce an
output object.
public R apply(T t);
21. Supplier<T>
• Do not get any argument object, only returns
instantiation of any object type.
public T get();
22. Bi?
BiPredicate<L, R> Compares two inputted object.
BiConsumer<T, U> Consumes two type of objects, and produce no result
BiFunction<T, U, R> Gets two input object (T , U) and produce a result (R)
.
.
.
23. Parallel Stream
• Any parallelizable operations can run
concurrently with Parallel stream object.
• Parallel Stream object can be obtain with
parallelStream() method from any Streamable
data structure.
24. Lazily & Eagerly Ops.
• Some Stream operations can be run Lazly as
some Eagerly.
Lazy Eager
• .filter().map().allMatch();
Lazy Eager
• .filter().filter().sorted().forEach();
25. Lazily & Eagerly
• Lazy operations are evaluated together with
first encountered Eager operation.
• The goal is evaluate chanied operations in
one step.
26. Defender Methods
• Before Java 8, Interfaces can contain only
abstract methods.
• With Java 8, any Interface can contain one or
more concrete methods that named
default/defender method.
• Tip: Default methods do not break nature of F I
onctional nterfaces
27. Defender Methods
• Defender Methods, Default Methods, Virtual extension methods
• Makes possible usage of concrete methods.
• Makes more elastic of Java Inheritance model.