title: Find the max number of contiguous duplicated characters in a String
body: <p>I need an updated version of my code which could return me the maximum number of the <strong>contiguous duplicated characters in a String</strong> e.g. in the case we have as an input the string <code>"aabbbcccccd"</code>
  then the <strong>result should be 5, since we have 5 c</strong>.</p>
  
  <p>The problem with my code is that it will return <strong>4</strong>.</p>
  
  <p><em>Note that in the case we have the input "<code>abccbbb</code>", the result should be 3 and not 4, since the strings contains 3 contiguous duplicated characters (the c).</em></p>
  
  <pre><code>private int countRepeatedChars(String password)
  {
      int maxNumberofRepeatedChars = 0;
      int counterOfSameChar = 0;
      boolean foundMoreThanOneChar = false;
  
      char ch, nextCh;
      for (int i = 0; i &lt; password.length()-1; i++) 
      {
          ch = password.charAt(i);
          nextCh = password.charAt(i + 1);
          if ((int) ch == ((int) nextCh)) 
          {
              counterOfSameChar++;
          } else 
          {
              maxNumberofRepeatedChars = Math.max(counterOfSameChar, maxNumberofRepeatedChars);
              counterOfSameChar = 0;
              foundMoreThanOneChar = true;
          }
      }
  
      if (foundMoreThanOneChar)
          return maxNumberofRepeatedChars;
      else
          return counterOfSameChar;
  }
  </code></pre>