2015年3月20日 星期五

java 8 lambda


1.  What is lambda ?
 * lambda is like a mathematics function f(x) = x +2, but it doesn't the name.
 * lambda in java is called function interface
 * lambda is anonymous interface and only one function

2. Lambda style

(input) -> {body}

3. example

Runnable runnbale = new Runnable() {
     public void run() {
      System.out.println("run me!");
     }
 }; 
 
 




Runnable runnbale = () -> System.out.println("run me!"); 
 
 
 
REF
Chinese: http://magiclen.org/java-8-lambda/
English more detail: more detail 
Explanation visual: visual
oracle function interface
oracle comsumer face





沒有留言:

張貼留言