/* class removeWhiteSpace { public static void main(String[] args) { String str1="Remove white spaces of the String"; //Removes the white spaces using regex str1 = str1.replaceAll(" ", ""); System.out.println(str1); } } */ class RemoveWhiteSpaces { public static void main(String[] args){ String str = "Remove white spaces of the String"; str = str.replaceAll(" ",""); System.out.println(str); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter