program to remove whitespaces within string
Java program to remove space within given string
public class Whitespaces {
public static void main(String[] args) {
String sentence = "T his is b ett er.";
System.out.println("Original sentence: " + sentence);
sentence = sentence.replaceAll("\\s", "");
System.out.println("After replacement: " + sentence);
}
}
public class Whitespaces {
public static void main(String[] args) {
String sentence = "T his is b ett er.";
System.out.println("Original sentence: " + sentence);
sentence = sentence.replaceAll("\\s", "");
System.out.println("After replacement: " + sentence);
}
}
Comments
Post a Comment