Created
September 1, 2020 02:51
-
-
Save adityaditiket/0de800ee9e8903dc4cd6604b3dec3478 to your computer and use it in GitHub Desktop.
replace multiple white space in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Ideone | |
{ | |
public static void main (String[] args) throws java.lang.Exception | |
{ | |
// your code goes here | |
String name = " hello there "; | |
String after = name.trim().replaceAll(" +", " "); | |
System.out.println("after="+after ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment