question: public static String encode ( String source ) { StringBuffer dest = new StringBuffer ( ) ; int sourceLen = source . length ( ) ; for ( int i = 0 ; i < sourceLen ; i ++ ) { int runLength = 1 ; final char currentChar = source . charAt ( i ) ; while ( i + 1 < sourceLen && currentChar == source . charAt ( i + 1 ) ) { runLength ++ ; i ++ ; } dest . append ( runLength ) ; dest . append ( currentChar ) ; } return dest . toString ( ) ; }
target:  Returns encoded string. For example, converts "WWWWWWWWWWWWBWWWWWWWWWWWWBBB" to "12W1B12W3B"