最新版eclipse支援java8

來源:互聯網
上載者:User

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));        }}




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.