Java program that removes all white spaces from the given string

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

  1. Hi there to everybody, it’s my first go to see of this web site; this weblog consists of awesome and in fact good stuff for visitors. Hurrah, that’s what I was exploring for, what stuff! Existing here at this blog, thanks admin of this web site. You can also visit String Interview Questions for more TutorialCup. related information and knowledge.

    ReplyDelete

Post a comment