replaceAll(" ", "")
을 사용하여 문자열의 모든 공백을 제거하려고 시도했지만 "hello world"
과 같은 텍스트는 공백뿐만 아니라 공백 뒤에 나오는 텍스트도 제거합니다. 즉, 결국은 "hello"
대신 "helloworld"
. 내가 도대체 뭘 잘못하고있는 겁니까?replaceAll ("", "")은 공백 ""뒤에 문자열의 모든 텍스트를 제거합니까?
public static void main (String [] args) {
String input;
Scanner console = new Scanner(System.in);
System.out.print("enter text: ");
input = console.next();
System.out.println();
input.replaceAll(" ", "");
System.out.println(input);
}
, 난 그냥 지금은 잘 작동하고 노력했다. 코드를 보여줄 수 있습니까? 'System.out.println ("Hello World".replaceAll ("", ""));'print HelloWorld' –
다음은 작동하는 예제입니다 : http://ideone.com/gGpIIZ –
장소? –