public class lambda02 {
public static void main(String[] args) {
/*
一直不理解lambda表达式中这种写法的含义知道看到匿名类
*/
//这是lambda表达式的写法
NumericTest isEven = n -> ( n % 2 ) == 0 ;
//这是匿名类实现的写法,瞬间开窍.
NumericTest test = new NumericTest() {
public boolean test(int n) {
return (n%2)==0 ;
}
}
}
}
interface NumericTest{
boolean test(int n);
}