No internet connection
  1. Home

Comments for http://horstmann.com/unblog/2019-07-23/index.html?utm_source=dlvr.it

By System @system
    2019-09-05 07:52:59.450Z
    • 6 comments
    1. P
      @p1729
        2019-09-05 07:52:59.557Z

        var counting = Collectos.of( should be Collector.of

        1. CCay Horstmann @cayhorstmann
            2019-09-05 11:26:18.637Z

            Thanks, I fixed that.

          • Q
            In reply tosystem:
            Yanming Zhou @quaff
              2019-12-16 07:06:15.964Z

              Collections.filtering should be Collectors.filtering

              1. CCay Horstmann @cayhorstmann
                  2020-07-03 19:27:42.922Z

                  Sorry about the late reply. I fixed that too.

                • L
                  In reply tosystem:
                  @lxsyojdzecdjuspcjh
                    2020-06-30 20:08:10.265Z

                    I think there might be an error in the first downstream collector example "first name to people" example.
                    I think the return type is slightly wrong, and also toMap() is not the right method. It probably should be:

                    Map<String, List<Person>> firstNameToPeople = people.collect( Collectors.groupingBy(Person::getFirstName, Collectors.toList()));

                    Similar with the second example
                    Map<String, Long> firstNameCount = people.collect( Collectors.groupingBy(Person::getFirstName, Collectors.counting()));

                    I attempt with Java 8, 11 and 14

                    Gregor

                    1. CCay Horstmann @cayhorstmann
                        2020-07-03 19:24:46.261Z

                        Thanks, you are right. I meant groupingBy. I fixed the code. NB. In a recent blog (https://horstmann.com/unblog/2020-06-05/index.html), I wrote about actually checking every line of code in a book. I've got to extend it to my blogs.