title: Advanced writing for grouping two collections with java, such as using stream API or other advanced type?
body: <p>I have two list, one is contain &quot;category&quot;, the other is contain some more detail, such as:</p>
  <pre class="lang-java prettyprint-override"><code>List&lt;String&gt; categoryList = new ArrayList&lt;&gt;(3);
  categoryList.add(&quot;cat&quot;);
  categoryList.add(&quot;dog&quot;);
  categoryList.add(&quot;bull&quot;);
  categoryList.add(&quot;other&quot;);
  
  List&lt;String&gt; detailList = new ArrayList&lt;&gt;();
  detailList.add(&quot;cat a&quot;);
  detailList.add(&quot;cat b&quot;);
  detailList.add(&quot;dog a&quot;);
  detailList.add(&quot;dog b&quot;);
  detailList.add(&quot;dog c&quot;);
  detailList.add(&quot;bull a&quot;);
  detailList.add(&quot;bird a&quot;);
  detailList.add(&quot;bird b&quot;);
  
  Map&lt;String, List&lt;String&gt;&gt; map = new HashMap&lt;&gt;();
  for (String category : categoryList) {
      map.put(category,new ArrayList&lt;&gt;());
  }
  
  boolean isFind = false;
  for (String detail : detailList) {
      isFind = false;
      for (String category : categoryList) {
          if (StrUtil.containsIgnoreCase(detail, category)) {
              map.get(category).add(detail);
              isFind = true;
              break;
          }
      }
      if (!isFind) {
          map.get(&quot;other&quot;).add(detail);
      }
  }
      System.out.println(map);
  </code></pre>
  <p>The output is :
  {other=[bird a, bird b], cat=[cat a, cat b], dog=[dog a, dog b, dog c], bull=[bull a]}</p>
  <p>I use the loop ,but i wonder if there are some advanced way to do it? thanks.</p>