I have a string like this:
mysz = \"name=john age=13 year=2001\";
I want to remove the whitespaces in the string. I tried trim()
trim()
public static void main(String[] args) { String s = "name=john age=13 year=2001"; String t = s.replaceAll(" ", ""); System.out.println("s: " + s + ", t: " + t); } Output: s: name=john age=13 year=2001, t: name=johnage=13year=2001