Write code to Return the size of substring that does not contain any trailing spaces
//package com.book2s; public class Main { public static void main(String[] argv) { String s = "book2s.com"; System.out.println(rightTrimSize(s)); }/*from www. j a v a 2s. c om*/ /** * Returns the size of substring that does not contain any trailing spaces * @param s the string * @return trimmed size */ public static int rightTrimSize(String s) { int i = s.length(); while (i > 0) { i--; if (s.charAt(i) != ' ') { return i + 1; } } return 0; } }