Commit 6f0aec66 by Patryk Czarnik

Dropne zmiany stylu w streamach

parent e54522cf
...@@ -14,14 +14,14 @@ public class SumaWJednymMiescie_Funkcyjnie { ...@@ -14,14 +14,14 @@ public class SumaWJednymMiescie_Funkcyjnie {
BigDecimal suma = lista.stream() BigDecimal suma = lista.stream()
.filter(r -> miasto.equalsIgnoreCase(r.miasto())) .filter(r -> miasto.equalsIgnoreCase(r.miasto()))
.map(r -> r.cena().multiply(BigDecimal.valueOf(r.sztuk()))) .map(r -> r.cena().multiply(BigDecimal.valueOf(r.sztuk())))
.reduce(BigDecimal.ZERO, (a, b) -> a.add(b)) .reduce(BigDecimal.ZERO, BigDecimal::add)
; ;
// wersja double // wersja double
double sumaD = lista.stream() double sumaD = lista.stream()
.filter(r -> miasto.equalsIgnoreCase(r.miasto())) .filter(r -> miasto.equalsIgnoreCase(r.miasto()))
.mapToDouble(r -> r.cena().doubleValue() * r.sztuk()) .mapToDouble(r -> r.cena().doubleValue() * r.sztuk())
.reduce(0.0, (a, b) -> a+b); .sum();
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(null,
"Suma BD = " + suma + "\nSuma db = " + sumaD); "Suma BD = " + suma + "\nSuma db = " + sumaD);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment