9
Java 8:使用换行符和缩进格式格式化lambda
我想通过lambda缩进实现以下内容: 多行语句: String[] ppl = new String[] { "Karen (F)", "Kevin (M)", "Lee (M)", "Joan (F)", "Des (M)", "Rick (M)" }; List<String> strings = Arrays.stream(ppl) .filter( (x) -> { return x.contains("(M)"); } ).collect(Collectors.toList()); strings.stream().forEach(System.out::println); 单行语句: List<String> strings = Arrays.stream(ppl) .map((x) -> x.toUpperCase()) .filter((x) -> x.contains("(M)")) .collect(Collectors.toList()); 当前,Eclipse将自动格式化为以下格式: 多行语句: String[] ppl …