-2
주어진 색인에서 특정 문자를 제거 할 수있는 코드를 작성하려고합니다. 그러나 "raw"공간을 사용할 때마다 일련의 오류가 발생합니다. 다음과 같은 내용이 있습니다.문자열의 공백으로 인해 오류가 발생합니다.
import java.util.*;
public class Test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner reader = new Scanner(System.in);
System.out.println("Enter a word");
String raw = reader.next();
System.out.println("Enter the number of the letter you would like to remove");
int x = reader.nextInt();
StringBuffer sbf = new StringBuffer(raw);
sbf.deleteCharAt(x-1);
String fixed = sbf.substring(0);
System.out.println(fixed);
}
}
어떤 오류가 있습니까? ... –