java remove whitespace from beginning of string code example
Example 1: how to remove all whitespace from string java
st = st.replaceAll("\\s+","")
Example 2: Which method in an be used to remove any whitespace from both the beginning and the end of a string?
str = "hello "
print(str.trim())
Example 3: remove spaces at beginning and end of string java
String withSpaces = " Hi ";
String withoutSpaces = withSpaces.trim();