Monday, 4 March 2013

IntelliJ Idea 12 with Java 8 Lambda

What is lambda in Java 8

1        http://www.lambdafaq.org/

Note - Java 8 Early Release has 2 build flavours. One is with lambda support and the other without lambda support. You can track the build stability on the test result page here.

Download and extract Java 8 binaries with Lambda - http://jdk8.java.net/lambda/


           

Download and Install IntelliJ Idea 12 - http://www.jetbrains.com/idea/download/index.html



Setting Up IntelliJ-Idea with Lambda JDK 8








Creating a Hello World Project with JDK 8 Lambda












Write a Sample Code with JDK 8 Lambda feature




 public class Main {  
   public static void main(String[] args) {  
     //Old way  
     Thread t1 = new Thread(  
         new Runnable() {  
           public void run() {  
             System.out.println("Thread t1!");  
           }  
         });  
     t1.run();  
     //Shorter way with Lambda  
     Thread t2 = new Thread( () -> { System.out.println("Thread t2!!"); } );  
     t2.run();  
     //Shortest way with Lambda  
     Runnable t3 = () -> { System.out.println("Thread t3!!!"); };  
     t3.run();  
   }  
 }  

Execute the Sample Code with JDK 8 Lambda feature


No comments:

Post a Comment