title: Count and the starting index of the largest string that has all chars same
body: <p>In a given string I want to find out the starting index of the largest sub-string that's all made of the same character, and also count how many times that substring occurs in the main string.</p>
  
  <p>ex: "aaakkkkbbkkkkk"
  In this case the count of the substring "kkkkk" is 5 and the starting position is 9.</p>
  
  <p>My code so far:</p>
  
  <pre><code>String str = "aaakkkkbbkkkkk";
  int count = 0;
  //converting string into character array
  char[] vals = str.toCharArray(); 
  
  for(int i=0; i &lt; vals.length; ){
  
     for(int j=i+1; j&lt;vals.length; j++){
         //if value match then increment counter
         if(vals[i]== str.charAt(j)){
             counter++;
         }
         //else break from inner loop 
         break; //break from inner loop
     }
     //assign the index value of j to the i to start with new substring
     i = vals.indexOf(j);
  }
  </code></pre>
  
  <p>My Issues: Unable to store counter value because this counter value is the actual occurrence of the substring, and later I'll compare substring with counter occurrence.</p>
  
  <p>I also not upto that mark with my logic.</p>