Java program examples

public class Test { public static void main(String[] args) { String str = “Learn Java with alegrucoding.com”; String result = str.replaceAll(“\\s”, “”); System.out.println(result); } } Output: LearnJavawithalegrucoding.com import org.apache.commons.lang3.StringUtils; public class Test { public static void main(String[] args) { String str = “Learn Java with alegrucoding.com”; String result = StringUtils.deleteWhitespace(str); System.out.println(result); } } Output: LearnJavawithalegrucoding.com

Read More Remove all whitespaces from a String in Java