Sau*_*mar 2 java java-8 java-stream
for (final Prices ppr : prices) {
if (!currency.getCode().equals(ppr.getCurrency().getCode())) {
continue;
}
return ppr.getPrice();
}
Run Code Online (Sandbox Code Playgroud)
上面的代码可以转换成Java流代码吗?我收到continue关键字错误...
return prices.stream()
.filter(ppr -> currency.getCode().equals(ppr.getCurrent().getCode()))
.findFirst()
.orElseThrow(NoSuchElementException::new);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
222 次 |
| 最近记录: |