title: counting occurrence of numbers in array
body: <p>I am stack for a while . I tried debugging but I couldn't figure out the solution. I am trying to count the occurrence of numbers. So my problem is that when I print the output it is </p>
  
  <pre><code>3 occurs 1 times
  1 occurs 1 times
  0 occurs 1 times
  2 occurs 1 times
  1 occurs 2 times
  3 occurs 2 times
  2 occurs 2 times
  0 occurs 2 times
  10 occurs 1 times
  4 occurs 1 times
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>1 occurs 2 times
  0 occurs 2 times
  2 occurs 2 times
  3 occurs 2 time
  10 occurs 1 times
  4 occurs 1 times 
  </code></pre>
  
  <p>so if the number has more than 1 occurrence it should say it only once not as many times as there is occurrences. Cheers Here is the code</p>
  
  <pre><code>import java.util.*;
  
  public class CountingOccuranceOfNumbers
  {
  
      public static void main(String[] args) 
      {
          countNumbers();
      }
  
      public static void countNumbers()
      {
          Scanner input = new Scanner(System.in);
          Random generator = new Random();
          int[] list = new int[11];
          int[] counts = new int[150];
          int counter = 0;
          int number = 1;
  
  
          while(counter &lt;= 10)
          {
                  number = generator.nextInt(11);
                  list[counter] = number;
                  counter++;
          }   
          for(int i=0; i&lt;list.length - 1; i++)
          {
              counts[list[i]]++;
  //          System.out.print(list[i] + " ");
  
              System.out.println(list[i] +" occurs " +  counts[list[i]] + " times");
          }
  
      }
  
  }
  </code></pre>