How do I replace characters in string?

package org.kodejava.example.lang;

public class StringReplace {
    public static void main(String[] args) {
        String text = "The quick brown fox jumps over the lazy dog";
        
        //
        // The replace method replace all occurrences of character 'o' with 'u'
        // and returns a new string object.
        //
        text = text.replace('o', 'u');
        System.out.println("Result: " + text);
    }
}

Wayan Saryada

Programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.

Leave a Reply