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
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
Step by Step Solution
There are 3 Steps involved in it
You can create a Java method called xChar to replace a specified character in a string with the X ch... View full answer
Get step-by-step solutions from verified subject matter experts
