question: public static String removeDuplicateWhitespace ( String s ) { StringBuilder result = new StringBuilder ( ) ; int length = s . length ( ) ; boolean isPreviousWhiteSpace = false ; for ( int i = 0 ; i < length ; i ++ ) { char c = s . charAt ( i ) ; boolean thisCharWhiteSpace = Character . isWhitespace ( c ) ; if ( ! ( isPreviousWhiteSpace && thisCharWhiteSpace ) ) { result . append ( c ) ; } isPreviousWhiteSpace = thisCharWhiteSpace ; } return result . toString ( ) ; }
target:  Remove all duplicate whitespace characters and line terminators are replaced with a single space.