In this short article, we will write a program that removes all white spaces from the given string.
All Java programs at all java programs
Write a program that removes all whitespaces from the given string
package com.java.tutorials.programs;
/**
*
* @author https://www.sourcecodeexamples.net/
*
*/
public class Java8Program {
public static void main(String[] args) {
String str = "source code examples";
String output = str.replaceAll("\\s", "");
System.out.println(" Output => " + output);
}
}
Output:
Output => sourcecodeexamples
Comments
Post a Comment