int sum = widgets.stream() .filter(w -> w.getColor() == RED) .mapToInt(w -> w.getWeight()) .sum(); In this example, widgets is a Collection<Widget> . We create ...
確定! 回上一頁