Write a method called parselTongue1 that takes a String, s and an int, n and returns a String with the first ’s’ repeated n times. There is an easy solution to this task that uses theString library methodreplaceFirst-lookthisupanduseitinyourmethod.
Write a second method called parselTongue2 that does the same task, but without using replaceFirst- you will need to work out your own way to do the task using other String methods.
In both cases the output should be the same, for example:
parselTongue1("hello", 6)
would return "hello"
parselTongue1("hospital", 3) would return "hossspital"
parselTongue2("hospital", 3) would return "hossspital"
In main display the result of calling this method several times with a variety of input data.
What I have tried:
public class ParselTongue{
public static void main(String[] args){
parselTongue("Hello",6);
parselTongue("hospital",3);
}
public static void parselTongue(String s, int n){
for(char a =0; a