Do lambda expressions have any use other than saving lines of code?

后端 未结 9 1471
我寻月下人不归
我寻月下人不归 2020-11-29 18:23

Do lambda expressions have any use other than saving lines of code?

Are there any special features provided by lambdas which solved problems which weren\'t easy to s

9条回答
  •  有刺的猬
    2020-11-29 19:01

    Lambdas are just syntactic sugar for anonymous classes.

    Before lambdas, anonymous classes can be used to achieve the same thing. Every lambda expression can be converted to an anonymous class.

    If you are using IntelliJ IDEA, it can do the conversion for you:

    • Put the cursor in the lambda
    • Press alt/option + enter

提交回复
热议问题