title: Collecting duplicates using a Java 8 stream
body: <p>I have a list of <code>cats</code>, and I want to group the <code>cats</code> with same <code>colour</code> and group them by <code>owner</code>. How do I do this in Java 8?</p>
  
  <pre><code>public class Cat{
      private String name;
      private Owner owner;
      private String color;
      public Cat(String name,Owner owner,String color){
          this.name=name;
          this.owner= owner;
          this.color= color;
      }
  }
  
  public class Owner{
      private String name;
      public Owner(String name){
          this.name= name;
      } 
  }
  </code></pre>
  
  <p>Lets say I have following data:</p>
  
  <pre><code>Owner owner1= new Owner("John");  Owner owner2= new Owner("Smith");
  Owner owner3= new Owner("Scott"); 
  Cat cat1 = new Cat ("Cat1",owner1,"Brown"); 
  Cat cat2 = new Cat ("Cat2",owner2,"Black");
  Cat cat3 = new Cat ("Cat3",owner1,"Brown");
  Cat cat4 = new Cat ("Cat4",owner3,"White");
  
  List&lt;Cat&gt; catList = new ArrayList&lt;&gt;();
  catList.add(cat1);
  catList.add(cat2);
  catList.add(cat3);
  catList.add(cat4);
  </code></pre>
  
  <p>I am expecting map of <code>owner1</code> which has two cats, <code>owner2</code> has 1 , <code>owner3</code> has 1 cat.</p>