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方法的主要内容,如果未能解决你的问题,请参考以下文章