【发布时间】:2021-06-08 08:07:05
【问题描述】:
我想知道这两个三段代码有什么区别:
underlyingConnectors.values().stream().forEach(connector -> connector.start());
underlyingConnectors.values().forEach(connector -> connector.start());
underlyingConnectors.values().forEach(Connector::start);
第二行编译正常,但我的 Ecplipse IDE 报错“Sonar : Replace this lambda with a method reference”。
如何选择要使用的合适代码?是否每个都有特定的用例?
【问题讨论】: