title: Question about ordering of parameters of Collector and Function in Java Streams
body: <p>So I'm looking into Java Streams and I have some questions about the meaning of the order of certain parameters.</p>
  <p>Some of the context:</p>
  <pre><code>public static List&lt;Person&gt; createPeople() {
      return List.of(new Person(&quot;Sara&quot;, 20), 
                     new Person(&quot;Sara&quot;, 22), 
                     new Person(&quot;Bob&quot;, 20), 
                     new Person(&quot;Paula&quot;,32), 
                     new Person(&quot;Paul&quot;, 32), 
                     new Person(&quot;Jack&quot;, 3), 
                     new Person(&quot;Jack&quot;, 72), 
                     new Person(&quot;Jill&quot;, 11));
      }
      
  
  List&lt;Person&gt; people = Section.createPeople();
  </code></pre>
  <p>Consider the following code:</p>
  <pre><code>Map&lt;String, Integer&gt; countByName3 = people.stream()
                                            .collect(groupingBy(Person::getName,
                                                                collectingAndThen(counting(), Long::intValue)));
  </code></pre>
  <p>The point of this code is to output a key value pair where the key is the name of the person and the value is the count of people with that particular name.</p>
  <p>Now where I am at in my understanding is that the collect method is taking Collector objects that are generated by functions in the Collectors class such as groupingBy as its argument.</p>
  <p>I also understand that there is a Function in the parameter of some of these methods. Something that interests me is the role that the order of the Function and the Collector in the method that generates a Collector object plays.</p>
  <p>For instance, groupingBy() takes its arguments in the order (Function, Collector), while collectingAndThen() takes its arguments in the order (Collector, Function). Both return Collectors if I am not mistaken.</p>
  <p>Thus, what is the meaning of the reversed order, is it indicative of how something is processed under the hood? And if there is a difference/meaning behind the order, can I get an explanation for that?</p>
  <p>Thanks very much.</p>