Java 8: Formatting lambda with newlines and indentation

后端 未结 9 1154
[愿得一人]
[愿得一人] 2020-12-12 23:46

What I would like to achieve with lambda indentation is the following:

Multi-line statement:

String[] ppl = new String[] { \"Karen (F)\", \"Kevin (M)         


        
9条回答
  •  鱼传尺愫
    2020-12-12 23:48

    I format single-line statement by adding empty comment "//" after functions.

    List list = Arrays.stream(x) //
                               .filter((n) -> n % 2 == 0) //
                               .map((n) -> n * 4) //
                               .boxed() //
                               .collect(Collectors.toList());
    

提交回复
热议问题