title: Java - Counting numbers in array
body: <p>I've written a java prog that stores some values:</p>
  
  <pre><code>public class array05 {
      public static void main(String[] args) {
  
          //placement of value
          int arryNum[] = {2,3,4,5,4,4,3};
  
          //placement of index, to start at 0
          for(int counter=0;counter&lt;arryNum.length;counter++){
              System.out.println(counter + ":" + arryNum[counter]);
          }
      }   
  }
  </code></pre>
  
  <p>which generate such output:
  <br />
  0:2 <br />
  1:3 <br />
  2:4 <br />
  3:5<br />
  4:4<br />
  5:4<br />
  6:3</p>
  
  <p>and now I need to count numbers in this output #1.
  Output #2 should be this:</p>
  
  <p>1: 0 <br />
  2: 1 <br />
  3: 2 <br />
  4: 3 <br />
  5: 1 </p>
  
  <p>It means it counts ONE 2, TWO 3, THREE 4, and only One 5.</p>
  
  <p>I am not sure how to write the code for output 2. 
  Is a binary search needed here?</p>
  
  <p>can anybody shed a light?</p>