Maximum consecutive repeating character in string | Java program to find the maximum consecutive repeating character in given string ; function to find out the maximum repeating character in given string ; Traverse string except last character ; If current character matches with next ; If doesn 't match, update result  (if required) and reset count ; Driver code
class GFG { static char maxRepeating ( String str ) { int n = str . length ( ) ; int count = 0 ; char res = str . charAt ( 0 ) ; int cur_count = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n - 1 && str . charAt ( i ) == str . charAt ( i + 1 ) ) cur_count ++ ; else { if ( cur_count > count ) { count = cur_count ; res = str . charAt ( i ) ; } cur_count = 1 ; } } return res ; } public static void main ( String args [ ] ) { String str = " aaaabbaaccde " ; System . out . println ( maxRepeating ( str ) ) ; } }