remove space from the end of 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+", "");