Home > AI > Language > Java > String >

replaceAll()

Example:

class Solution{

    public static void main(String []arg)
    {
        String sample = "123 123 123 123 321";
        String replaced = sample.replaceAll("123", "111");
        System.out.println("orginal string: " + sample);
        System.out.println("replaced string: " + replaced);
    }
}

Leave a Reply