The latest version of the Eclipse SDK Version:luna (4.4) Build id:i20140318-0830 download Link: http://download.eclipse.org/eclipse/downloads/
1. Select the version selected in the following figure:
2. Select your system corresponding SDK, I am the following figure specified version, (X86 system)
3. After the download, unpack and open eclipse. To use the Java8 feature, you also need to install JDK1.8, which is not detailed. Then eclipse needs to be configured.
In the window--->preference, set the following figure:
Select compiler to set the compiler version, we select 1.8, the following figure:
Finally, it's OK to set the JDK path. The following figure, my jdk1.8 is installed in the "D:\Program files\java\jdk1.8.0"
Then create a new Java project Test Java 8 lambda expression = = Test results are as follows:
Code:
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 ("+ 2 =" +
myapp.operatebinary (2, addition));
System.out.println ("20-10 =" +
myapp.operatebinary (M, subtraction));
}