Write a recursive, string -valued method, replace, that accepts a string and returns a new string consisting of the original string with each blank replaced with an asterisk (*) Replacing the blanks in a string involves: Nothing if the string is empty Otherwise: If the first character is not a blank, simply concatenate it with the result of replacing the rest of the string If the first character IS a blank, concatenate an * with the result of replacing the rest of the string

LANGUAGE: JAVA

CHALLENGE:

Write a recursive, string -valued method, replace, that accepts a string and returns a new string consisting of the original string with each blank replaced with an asterisk (*)
Replacing the blanks in a string involves:
Nothing if the string is empty
Otherwise:
If the first character is not a blank, simply concatenate it with the result of replacing the rest of the string
If the first character IS a blank, concatenate an * with the result of replacing the rest of the string

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

Leave a Comment

You must be logged in to post a comment.