当前位置:网站首页>Example 1 of lambda expression

Example 1 of lambda expression

2022-06-10 09:43:00 Leon_ Jinhai_ Sun

When we create a thread and start it, we can use the writing method of anonymous inner class :

new Thread(new Runnable() {
    @Override
    public void run() {
        System.out.println(" You know what?   I'm better than you think   I want to be by your side ");
    }
}).start();

have access to Lambda Modify it in the format of . Revised as follows :

new Thread(()->{
    System.out.println(" You know what?   I'm better than you think   I want to be by your side ");
}).start();

原网站

版权声明
本文为[Leon_ Jinhai_ Sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100934098491.html