Removing white spaces

Method 1:
String s = "This is a sentence";
String s2 = s.trim();


Method 2:
String s = "This is a sentence";
String s2 = s.replaceAll("\\s", "");

No comments:

Post a Comment