You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zanninso 79c9245fd8
fix: change StringContain -> StringReplace (#2095)
1 year ago
..
README.md fix: change StringContain -> StringReplace (#2095) 1 year ago

README.md

StringReplace

Instructions

Create a file StringReplace.java.

Write a function called StringReplace that takes in three parameters: original_string s, target, and replacement. The function should replace all occurrences of target in original_string s with replacement and return the modified string.

Expected Functions

public class StringReplace {
    public static String replace(String s, target, replacement) {
        // your code here
    }
}

Usage

Here is a possible ExerciseRunner.java to test your function :

public class ExerciseRunner {
    public static void main(String[] args) {
        System.out.println(StringReplace.replace("javatpoint is a very good website", 'a', 'e'));
        System.out.println(StringReplace.replace("my name is khan my name is java", "is","was"));
        System.out.println(StringReplace.replace("hey i'am java", "I'am","was"));
    }
}

and its output :

$ javac *.java -d build
$ java -cp build ExerciseRunner
jevetpoint is e very good website
my name was khan my name was java
hey i'am java
$

Notions

String