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