why is x.replaceAll("\\s+","")
is removing the first space and everything after it? if x
was originally a a
after doing replaceAll()
and printing x
, it only prints a
not aa
.
this is part of a larger project, but for testing purposes I tried it separately on a new java main file and still does the same thing this is the full complete program:
import java.util.*;
public class test {
public static void main (String args[]){
Scanner input = new Scanner(System.in);
String y = input.next();
String x = y.replaceAll("\\s+","");
System.out.println(x);
}
}