create a method called xChar that will replace a specified char in a String with the 'X'
Fantastic news! We've Found the answer you've been seeking!
Question:
create a method called xChar that will replace a specified char in a String with the 'X' character. The method must use a pointer to search and replace the char. The method should take as arguments the String to search through and a char variable that holds the char to be searched for and replaced.
The method should return a String that has been modified.
Note:
Strings in Java are immutable. This means they cannot be changed. For this question simply copy all characters to a new string replacing the character to search for with the 'X' character.
Example Run:
Enter some text
Hello World
Enter a character to x
o
Here is your output
Hellx Wxrd
Related Book For
Posted Date: