Question: public static void String replacement (String ori, String r, String w) This method should replace all occurrences of the String r with the String w

public static void String replacement (String ori, String r, String w)

This method should replace all occurrences of the String r with the String w if the total length of String r (number of ocurrence X r.length()) is less than 30% of the length of ori String; otherwise, you are going to replace all ocurrences of w with r. Then return a String after applying these rules:

replacement("Skiiing is fun", "fun","cool") should return "Skiing is cool"

replacement("AAABB","A","C") should return "AAABB"

replacement("AAABB", "A","B") should return "AAAAA"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!