Question: Write a method echo that accepts a String as a parameter and returns a string with each word repeated twice. Assume each word is preceded
Write a method echo that accepts a String as a parameter and returns a string with each word repeated twice. Assume each word is preceded by a single space and at least one space exists.Sample below:
System.out.println(echo("hello there java world")); // hello hello there there java java world world
System.out.println(echo("1 2 3 4 5")); // 1 1 2 2 3 3 4 4 5 5 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
