<分区>
我试图只从第一个和第二个索引中删除每个“x”而不考虑大小写,但我的程序只删除第一个索引的字母然后循环而不删除第二个。
Scanner userIn = new Scanner(System.in);
StringBuilder str = new StringBuilder();
str.append(userIn.nextLine());
for(int i = 0; i<2; i++) {
if((str.charAt(i) == 'x') || (str.charAt(i) == 'X')) {
str = str.deleteCharAt(i);
}
}
System.out.println(str);