fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  7.  
  8. import static java.util.stream.Collectors.*;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. interface Customer {
  14. String getName();
  15. BigDecimal getSalary();
  16. }
  17.  
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. Map.Entry<Long, List<Customer>> entry = Map.entry(0L, List.of());
  21.  
  22. Map<String, BigDecimal> map = entry.getValue().stream()
  23. .collect(groupingBy(Customer::getName,
  24. reducing(BigDecimal.ZERO, Customer::getSalary, BigDecimal::add)));
  25.  
  26. System.out.println("Success");
  27. }
  28. }
Success #stdin #stdout 0.1s 48936KB
stdin
Standard input is empty
stdout
Success