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