title: Java count occurrence of each item in an array
body: <p>Is there any method for counting the occurrence of each item on an array?</p>
  
  <p>Lets say I have:</p>
  
  <pre><code>String[] array = {"name1","name2","name3","name4", "name5"};
  </code></pre>
  
  <p>Here the output will be:</p>
  
  <pre><code>name1 1
  name2 1
  name3 1
  name4 1
  name5 1
  </code></pre>
  
  <p>and if I have:</p>
  
  <pre><code>String[] array = {"name1","name1","name2","name2", "name2"};
  </code></pre>
  
  <p>The output would be:</p>
  
  <pre><code>name1 2
  name2 3
  </code></pre>
  
  <p>The output here is just to demonstrate the expected result.</p>