remove a space at the end of a string java code example
Example 1: remove spaces at beginning and end of string java
String withSpaces = " Hi ";
String withoutSpaces = withSpaces.trim();
Example 2: remove space string java
a = a.replaceAll("\\s+", "");