String remove trailing spaces java code example
Example 1: how to strip trailing spaces in java
String str = new String(" apples ");
str.trim(); // result is a nes string "apple"
Example 2: remove space string java
a = a.replaceAll("\\s+", "");
String str = new String(" apples ");
str.trim(); // result is a nes string "apple"
a = a.replaceAll("\\s+", "");