replace String with another in java

前端 未结 6 1740
孤城傲影
孤城傲影 2020-11-22 08:14

What function can replace a string with another string?

Example #1: What will replace \"HelloBrother\" with \"Brother\"?

Example #2

6条回答
  •  悲哀的现实
    2020-11-22 09:02

    There is a possibility not to use extra variables

    String s = "HelloSuresh";
    s = s.replace("Hello","");
    System.out.println(s);
    

提交回复
热议问题