Java Tutorial

Java String stripTrailing() method

TGTeam GyaniPanditSeptember 12, 20221 min read

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());
}
}

Turn reading into skillsCertificate courses in AI, Data Science and programming.
Explore Courses