Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Replace String in Java

/* 1. Replace following sentence with “Mercedes best german car” to “BMW best german car” */

public class HelloWorld {

    public static void replace(){
        String Text = "Mercedes is the best German car!";
        String change = "Mercedes"; 
        String replace = "BMW";
        System.out.println(Text.replace(change, replace));
    }

    public static void main(String []args) {
        replace();
    }
    
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.