如何编写system.out.println作为方法参考?

维基·贾恩

我正在使用foreach迭代Collection,正在使用intelliJ IDE。

queue.forEach(s->{
            System.out.println(s);
        });

我在这里警告“可以用方法引用代替。”

有人可以建议如何在这里使用方法引用吗?

pvpkiran
System.out::println

这应该做

queue.forEach(System.out::println);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章