String的replace方法

Posted lay2017

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了String的replace方法相关的知识,希望对你有一定的参考价值。

public class Test {
    public static void main(String args[]) {
        String Str = new String("hello");

        System.out.print("返回值 :" );
        System.out.println(Str.replace(‘o‘, ‘T‘));

        System.out.print("返回值 :" );
        System.out.println(Str.replace(‘l‘, ‘D‘));
    }
}
返回值 :hellT
返回值 :heDDo

 

以上是关于String的replace方法的主要内容,如果未能解决你的问题,请参考以下文章

调用 replace() 时片段的生命周期是啥?

FragmentTransaction.replace() 淡入过渡显示“幽灵”片段

片段行为:FragmentTransaction::replace() 和反向 backStack 操作

python 字符串替换功能 string.replace()可以用正则表达式,更优雅

String的replace方法怎么转换带有特殊字符的子字符串?

java 中replace方法?