编程知识 cdmana.com

The use of lambda expression

public class lambda {
    public static void main(String[] args) {
        
        // Method 1 , The anonymous inner class is used here 
        Ilove like1= (int a) -> {
            System.out.println("I love lambda" + a);

        };

        like1.gan(10);
        // Method 2; Traditional approach 
        Ilove like2=new like();
        like2.gan(100);
    }
}
interface Ilove{
    void gan(int a);


}
class like implements Ilove {

    @Override
    public void gan(int a) {
        System.out.println("I love lambda" + a);


    }
}

版权声明
本文为[8Years]所创,转载请带上原文链接,感谢

Scroll to Top