-2
我正在尝试编写代码,使我可以删除特定索引处字符串的特定字符。但是,每当我在“原始”中使用空格时,我都会遇到一系列错误。 我有以下。字符串中的空格导致错误
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);
}
}
什么错误?... –