title: Frequency of elements in an array
body: <p>I am relatively new to programming and i have been working on a java project for about 2 days that reads ten numbers and displays the frequency of occurrence of each number , while my code looks good and it run ,it doesnt seem to be able to count two numbers that are far apart even after sorting ,please i have run out of ideas and am open to suggestions </p>
  
  <p>Here's my code:</p>
  
  <pre><code>public static void sortarray(int [] tennumbersarray ){
      for(int i =0 ;i&lt;9;i++){
          int currentmin = tennumbersarray[i];
          int currentminindex = i;
          for(int j=i+1;j&lt;10;j++){
              if(currentmin&gt;tennumbersarray[j]){
                  currentmin= tennumbersarray[j];
                  currentminindex = j;
              }
          }
          if(currentminindex!=i){
              tennumbersarray[currentminindex]=tennumbersarray[i];
              tennumbersarray[i]=currentmin;
          }
      }
  }
  public static void main(String[] args) {
      int tennumbersarray [] = new int[10];
      for (int i =0 ;i&lt;10;i++){
          String tennumbersstring = JOptionPane.showInputDialog("enter a number :");
          tennumbersarray [i] = Integer.parseInt(tennumbersstring);
      }
  
      sortarray ( tennumbersarray);
  
      for (int i=0;i&lt;10;i++){            
           int count =1;
           for (int j=i+1;j&lt;10;j++)
           {
               if(tennumbersarray[i]==tennumbersarray[j])
               {
                   count++;
               }
               else{
                   break;
               }
           }
           String output = ""+tennumbersarray[i] +"----&gt; "+count;
           JOptionPane.showMessageDialog (null,output);
           i+=count;
       }
   }
   }
  </code></pre>