title: Character counter in Java
body: <p>So far this is what I tried:</p>
  
  <pre><code>public class CharacterCounter {
  
  public static void main(String[] args){
  
      String string = "sashimi";
  
      int count = 0;
      for(int i =0; i &lt; string.length(); i++){
          if(string.charAt(i) == 'i'){
              count++;
              }
      }
  
      System.out.println("The number of letter i is " + count);
  
  } 
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code> The number of letter i is 2
  </code></pre>
  
  <p>But what I wanna do is, the program should count the most occurred characters.</p>
  
  <p>For example here the string is <strong>SASHIMI</strong>, the output should be:</p>
  
  <pre><code> the number of letter S is 2
   the number of letter I is 2
  </code></pre>
  
  <p>I'm stuck with this problem. I need your help. Thanks.</p>