fork(1) download
  1. import java.util.*;
  2. import java.util.stream.*;
  3.  
  4. class Ideone {
  5. public static void main(String[] args) throws java.lang.Exception {
  6. System.out.println(
  7. IntStream.range(0, 2_000_000)
  8. .map(
  9. i -> {
  10. Random random = new Random();
  11. return ((random.nextInt(91) + 10));
  12. })
  13. .boxed()
  14. .collect(Collectors.groupingBy(s -> s / 10.0, Collectors.counting()))
  15. .entrySet()
  16. .stream()
  17. .sorted(Comparator.comparing(a -> a.getKey()))
  18. .collect(Collectors.toList()));
  19. }
  20. }
  21.  
Success #stdin #stdout 0.35s 4386816KB
stdin
Standard input is empty
stdout
[1.0=22093, 1.1=21803, 1.2=21878, 1.3=22069, 1.4=22070, 1.5=21828, 1.6=21998, 1.7=21862, 1.8=22157, 1.9=21948, 2.0=21992, 2.1=21863, 2.2=21967, 2.3=22101, 2.4=21880, 2.5=22160, 2.6=21850, 2.7=21931, 2.8=21969, 2.9=21787, 3.0=21641, 3.1=21937, 3.2=22274, 3.3=22327, 3.4=21994, 3.5=21950, 3.6=22036, 3.7=21907, 3.8=21949, 3.9=22031, 4.0=21873, 4.1=21910, 4.2=22129, 4.3=21826, 4.4=22017, 4.5=21923, 4.6=22191, 4.7=22040, 4.8=22146, 4.9=22003, 5.0=21706, 5.1=21876, 5.2=22049, 5.3=21913, 5.4=22174, 5.5=22204, 5.6=22058, 5.7=22136, 5.8=21962, 5.9=21775, 6.0=21859, 6.1=21824, 6.2=21743, 6.3=21997, 6.4=21995, 6.5=21993, 6.6=21784, 6.7=21979, 6.8=21959, 6.9=22179, 7.0=21902, 7.1=22266, 7.2=22075, 7.3=22046, 7.4=21996, 7.5=21656, 7.6=22150, 7.7=22045, 7.8=21912, 7.9=21868, 8.0=22071, 8.1=21800, 8.2=22181, 8.3=21924, 8.4=22043, 8.5=21976, 8.6=22024, 8.7=22006, 8.8=22063, 8.9=21952, 9.0=22016, 9.1=22215, 9.2=22035, 9.3=22111, 9.4=21869, 9.5=21812, 9.6=21983, 9.7=21847, 9.8=21845, 9.9=21968, 10.0=21868]