title: Java: count of elements in a list
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/505928/how-to-count-occurrence-of-an-element-in-a-list">How to count occurrence of an element in a List</a>  </p>
  </blockquote>
  
  
  
  <p>I have a list like <code>List&lt;String&gt; A={12, 12, 14, 16, 16}</code>. How can I find the number of elements distinctly as</p>
  
  <pre><code>12-&gt;2
  14-&gt;1
  16-&gt;2
  </code></pre>
  
  <p>by using a function like <code>countElements(A,"12")</code> or <code>A.count("12")</code>? Is there a library or a function?</p>