title: Check if a character appears more than once in a string using charAt() and loop
body: <p>The code is giving characters for consecutive appearances and not for non-consecutive repetition of a character in a string. Using function can be easy but I want to use loop and use <code>charAt</code> in it to compare.</p>
  
  <pre><code>int count = 0;
  for (int i = 0; i &lt; str.length(); i++) {        
      if(str.charAt(i)==str.charAt(i+1)) {
          count++;
      }
      return count;
  }
  </code></pre>