Can be replaced with method reference less 可以用代码更少的方法引用代替
1.警告
IDEA 提示Can be replaced with method reference less 可以用代码更少的方法引用代替
// 该写法会提示该警告
list.forEach(
s -> System.out.println(s)
);
2.解决
// 使用方法引用消除警告
list.forEach(
System.out::println
);
Can be replaced with method reference less 可以用代码更少的方法引用代替
阅读 112
2022-05-26
IDEA 提示Can be replaced with method reference less 可以用代码更少的方法引用代替
// 该写法会提示该警告
list.forEach(
s -> System.out.println(s)
);
// 使用方法引用消除警告
list.forEach(
System.out::println
);
相关推荐
精彩评论(0)