question: public static String trimTrailingWhitespace ( String str ) { if ( ! hasLength ( str ) ) { return str ; } StringBuilder sb = new StringBuilder ( str ) ; while ( sb . length ( ) > 0 && Character . isWhitespace ( sb . charAt ( sb . length ( ) - 1 ) ) ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } return sb . toString ( ) ; }
target:  Trim trailing whitespace from the given String.