how to remove spaces in a string java 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 space string java
a = a.replaceAll("\\s+", "");
Example 4: java remove space at the end of string
String str = "Hello ";
System.out.println(str.trim()); // "Hello"