下面的示例演示如何使用removeCharAt(string,position)方法从字符串中的特定位置删除字符。
public class Sample {
public static void main(String args[]) {
String str = "this is Java";
System.out.println(removeCharAt(str, 3));
}
public static String removeCharAt(String s, int pos) {
return s.substring(0, pos) + s.substring(pos + 1);
}
}输出结果
this is Java