StripTrailing Method
With this method, we can cut the trailing whitespaces (the whitespaces at the end) from the string. Have a look at the below program and try to implement it and observe the results.
public class StringMethods {
public static void main(String[] args) {
String spaces = ” Java “;
System.out.println(spaces.stripTrailing());
}
}