how to remove all whitespace from string java
st = st.replaceAll("\\s+","")
how to remove all whitespace from string java
st = st.replaceAll("\\s+","")
java 8 remove spaces from string
a.replaceAll("\\s+","");
how to remove white space between numbers in a string in java
White space means blank space i
remove extra blank spaces from string in java
import java.util.Scanner;
class RemoveExtraSpace{ //starting of class
public static void main(String[] args){ //starting of the main function
Scanner sc=new Scanner(System.in); //declaring an object of the Scanner class
String input,output="";
char c;
int i,len;
System.out.println("ENTER A SENTENCE.");
input=sc.nextLine().trim(); //accepting the input
len=input.length();
for(i=0;i<len;i++){ //outer for loop to traverse each character
c=input.charAt(i);
output+=c;
if(c==' '){
while(input.charAt(i)==' '){ //inner while loop to skip through repeated spaces
i++;
} //end of while loop
i--; //decrementing i by 1 so that the immediate character after space is taken
}
} //end of for loop
System.out.println(output); //printing the result
} //closing of main function
} //closing of class
how to remove white space between numbers in a string in java
"Hello 111 222 333 World!"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us