Count occurrences of current character
if ( str . charAt ( i ) == str . charAt ( i - 1 ) ) { count ++ } else { System . out . print ( str . charAt ( i ) ) ; System . out . print ( count ) ; count = 1 }