static int findEndOfString(String sb) {
        int result;
        for (result = sb.length(); result > 0; result --) {
            if (!Character.isWhitespace(sb.charAt(result - 1))) {
                break;
            }
        }
        return result;
    }
static int findEndOfString ( String sb ) { int result ; for ( result = sb . length ( ) ; result > 0 ; result -- ) { if ( ! Character . isWhitespace ( sb . charAt ( result - 1 ) ) ) { break ; } } return result ; }
Find the end of String
@return the rank of the end of string