JAVA8 Lambda 函数式代码开发

 
public class Lambda {
    public static void main(String[] args) {
        //未简化
        S s = new S() {
            @Override
            public void s() {
                System.out.println("123");
            }
        };
        s.s();
 
        //简化
        S s1 = ()->{
            System.out.println("Lambda简化");
        };
        s1.s();
    }
 
 
}
interface S{
  void s();
}

  

 

猜你喜欢

转载自www.cnblogs.com/gjths/p/12199319.html