java removing spaces from string code example
Example 1: how to remove all whitespace from string java
st = st.replaceAll("\\s+","")
Example 2: java 8 remove spaces from string
a.replaceAll("\\s+","");
Example 3: remove spaces at beginning and end of string java
String withSpaces = " Hi ";
String withoutSpaces = withSpaces.trim();
Example 4: remove space string java
a = a.replaceAll("\\s+", "");