删除字符串中的一个字符

删除字符串中的一个字符

public class Main {//删除字符串中的一个字符

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);

}

}

 

posted @ 2021-10-06 17:21  慢漫曼蔓  阅读(348)  评论(0)    收藏  举报