eclipse SDK的最新版本 Version: Luna (4.4) Build id: I20140318-0830 下載連結:http://download.eclipse.org/eclipse/downloads/
1. 選擇下圖選定的版本:
2. 選擇你系統對應的SDK,本人的是下圖指定的版本,(X86系統)
3. 下載好之後,解壓開啟eclipse。要使用java8的特性,你還需要安裝JDK1.8,這個就不詳述了。然後eclipse裡面需要配置一下。
在window--->preference裡面設定如下圖:
選擇compiler設定編譯器的版本,我們選擇1.8的,如下圖:
最後,設定JDK路徑就行了。如下圖,我的jdk1.8是安裝在“D:\Program Files\Java\jdk1.8.0”
然後建立一個java 工程測試一下java 8 的lambda運算式==測試結果如下:
代碼:
public class Calculator { interface IntegerMath { int operation(int a, int b); } public int operateBinary(int a, int b, IntegerMath op) { return op.operation(a, b); } public static void main(String... args) { Calculator myApp = new Calculator(); IntegerMath addition = (a, b) -> a + b; IntegerMath subtraction = (a, b) -> a - b; System.out.println("40 + 2 = " + myApp.operateBinary(40, 2, addition)); System.out.println("20 - 10 = " + myApp.operateBinary(20, 10, subtraction)); }}