我正在尝试打印没有中间字符的字符串,但我没有得到所需的输出。
public class StringIndexEliminator {
public static void main(String[] args) {
String str = "CARS";
int l = str.length();
int s = (l+1)/2;
System.out.println(l);
StringBuffer sb = new StringBuffer(str);
System.out.println(sb.deleteCharAt(s).toString());
}
}