Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Revolution of JavaJava 8 – Project Lambda
About Me• Java Developer• Technical Teacher• Blogger @kodcu.com
Java 8 Innovations• Lambda Expressions• Type Inference• Metod References• Collection II• Defender Methods
Functional Interface ?• An Interface includes only one abstract  method called as FunctionalInterface• Lambda expressions ...
Functional Interface Examps.• java.lang.Runnable• java.util.concurrent.Callable• java.nio.file.PathMatcher• java.lang.refl...
Lambda Expressions• Lambda -> (also called Closures), is an expression  that reduces vertical boilerplate code.• Concise a...
Focus to Input & OutputRunnable r1=new Runnable() {        @Override             Input        public void run() {         ...
Example
Lambda Types• 2 type  – Single expression // no need “return”     • (Integer s) -> ( s*2 );     • |or| (Integer s) -> s*2 ...
Type Inference(String s) -> { System.out.println(s); };// equals(s) -> { System.out.println(s); };// equalss   -> { System...
Type Inference(Integer   a, Integer b)    -> a + b;// equals(a,b) -> (a+b);
Metod ReferencesRunnable r1=new Runnable() {        @Override             Input        public void run() {             Out...
Metod References
Collection II• Collection II is an attachment to existing  Collection Framework.• Supports Jquery like chained methods and...
Collection II• Existing Collection Framework does not  support Concurrent operations in  chunked datas.• Cause, existing o...
Stream <T> Interface• Sequential and Consumable data structure.• The data cannot be fetch again after consumed.• A Stream ...
java.util.function         Functional Interfaces• Those special Interfaces  support general data  operations.
Consumer<T> -> Applying• Consumer gets an input and runs an action.• Does not return any result, only do an action.  publi...
Predicate<T> -> Filtering• Predicate gets a conditional code and  produce -> true || false• In concise, makes filtering.  ...
Function<T, R> -> (Consume & Produce);• Gets any type of input object and Produce an  output object.     public R apply(T ...
Supplier<T>• Do not get any argument object, only returns  instantiation of any object type.    public T get();
Bi?BiPredicate<L, R>    Compares two inputted object.BiConsumer<T, U>     Consumes two type of objects, and produce no res...
Parallel Stream• Any parallelizable operations can run  concurrently with Parallel stream object.• Parallel Stream object ...
Lazily & Eagerly Ops.• Some Stream operations can be run Lazly as  some Eagerly.         Lazy          Eager• .filter().ma...
Lazily & Eagerly• Lazy operations are evaluated together with  first encountered Eager operation.• The goal is evaluate ch...
Defender Methods• Before Java 8, Interfaces can contain only  abstract methods.• With Java 8, any Interface can contain on...
Defender Methods• Defender Methods, Default Methods, Virtual extension methods• Makes possible usage of concrete methods.•...
Defender Methods• Defender methods can be re-implemented or  inherited by other Interfaces.
???????????????   Q/A??????????
Próxima SlideShare
Cargando en…5
×

Java 8 - Project Lambda

This slide contains about Java 8 - Project Lambda that demonstrated İstanbul Java Day 2013

  • Sé el primero en comentar

Java 8 - Project Lambda

  1. 1. Revolution of JavaJava 8 – Project Lambda
  2. 2. About Me• Java Developer• Technical Teacher• Blogger @kodcu.com
  3. 3. Java 8 Innovations• Lambda Expressions• Type Inference• Metod References• Collection II• Defender Methods
  4. 4. Functional Interface ?• An Interface includes only one abstract method called as FunctionalInterface• Lambda expressions are converted to a FI’s implementation in Background
  5. 5. Functional Interface Examps.• java.lang.Runnable• java.util.concurrent.Callable• java.nio.file.PathMatcher• java.lang.reflect.InvocationHandler• java.beans.PropertyChangeListener• java.awt.event.ActionListener
  6. 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)
  7. 7. Focus to Input & OutputRunnable r1=new Runnable() { @Override Input public void run() { Output System.out.println(“Hello Uranus."); } };
  8. 8. Example
  9. 9. Lambda Types• 2 type – Single expression // no need “return” • (Integer s) -> ( s*2 ); • |or| (Integer s) -> s*2 ; – Statement Block • (Integer s) -> { return s*2; };
  10. 10. Type Inference(String s) -> { System.out.println(s); };// equals(s) -> { System.out.println(s); };// equalss -> { System.out.println(s); };
  11. 11. Type Inference(Integer a, Integer b) -> a + b;// equals(a,b) -> (a+b);
  12. 12. Metod ReferencesRunnable r1=new Runnable() { @Override Input public void run() { Output System.out.println(“Hello Uranus."); } };
  13. 13. Metod References
  14. 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. 15. Collection II• Existing Collection Framework does not support Concurrent operations in chunked datas.• Cause, existing one applies External Iteration.
  16. 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. 17. java.util.function Functional Interfaces• Those special Interfaces support general data operations.
  18. 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. 19. Predicate<T> -> Filtering• Predicate gets a conditional code and produce -> true || false• In concise, makes filtering. public boolean test(T t);
  20. 20. Function<T, R> -> (Consume & Produce);• Gets any type of input object and Produce an output object. public R apply(T t);
  21. 21. Supplier<T>• Do not get any argument object, only returns instantiation of any object type. public T get();
  22. 22. Bi?BiPredicate<L, R> Compares two inputted object.BiConsumer<T, U> Consumes two type of objects, and produce no resultBiFunction<T, U, R> Gets two input object (T , U) and produce a result (R) . . .
  23. 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. 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. 25. Lazily & Eagerly• Lazy operations are evaluated together with first encountered Eager operation.• The goal is evaluate chanied operations in one step.
  26. 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. 27. Defender Methods• Defender Methods, Default Methods, Virtual extension methods• Makes possible usage of concrete methods.• Makes more elastic of Java Inheritance model.
  28. 28. Defender Methods• Defender methods can be re-implemented or inherited by other Interfaces.
  29. 29. ??????????????? Q/A??????????

×