qcq0703

参考链接:https://blog.csdn.net/ling1234ling1234/article/details/87805889

原因是,替换的新的字符串返回值没有被接收。

为了去掉"abcdefg"中间的c

public class Main {
    public static void main(String[] args) {
        String s = "abcdefg";
        s.replace("c","");
        System.out.println(s);
    }

}

//输出结果abcdefg

问题所在就是s= s.replace("","");需要一个变量在接受他的返回值

public class Main {
    public static void main(String[] args) {
        String s = "abcdefg";
        s = s.replace("c","");
        System.out.println(s);
    }
}

//输出结果abdefg
以下为api

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
相关资源
相似解决方案