Return value by lambda in Java

后端 未结 3 1920
遥遥无期
遥遥无期 2021-02-13 15:24

Till now I manage to find all answers I need but this one confusing me. Let\'s say we have example code:

public class Animal {
   private String species;
   priv         


        
3条回答
  •  感情败类
    2021-02-13 15:39

    Yes, when specifying only a single statement, its value is automatically returned from the lambda.

    Then, since Runnable is a Functional Interface, it can be defined as a lambda. The return type is void, so any return value inside the lambda will be ignored.

提交回复
热议问题