How to autocomplete lambdas in IntelliJ IDEA?

前端 未结 2 877
时光说笑
时光说笑 2021-02-01 17:13

I\'m using IntelliJ IDEA 13 with Java 8 and wonder how to autocomplete lambdas. Before Java 8 I used anonymous inner classes of course. I auto completed by typing \"new\" and hi

2条回答
  •  情歌与酒
    2021-02-01 18:07

    You can just type p = s -> f..., autocompletion will then suggest false. If you're not sure about lambda, you can start with the inner class, and then turn it into a lambda expression.

    In your example you can press Alt+Enter afterwards, as follows:

    After completing:

    After completing

    After pressing Alt+Enter:

    After pressing Alt+Enter

    Result:

    Result

    Clicking the small icon at the gutter shows you the Predicate.test method. Override icon at gutter

提交回复
热议问题