Please implement this recursive method in Java:
public static int replaceCells​(char[][] array, int x, int y, char target, char replacement) {}
This method replaces a character and instances of the character that are adjacent to it, with a replacement character.
The method determines whether a character at position x,y of the array corresponds to a target character.
If that is not the case, no further processing will take place.
Otherwise:
1. The character at position x,y will be replaced with the replacement character.
2. We will apply the same processing to the surrounding array entries (if any) of x,y.
Do not rely on exceptions to identify whether an x,y pair represents a set of valid indices (valid means that x,y is associated with an array entry).
It is recommended that you define a non-recursive method that tells you whether an x,y pair is valid.
This method is not an auxiliary method that supports the recursion.
You may only use one auxiliary method that supports the recursive process. Your implementation must be recursive and you may not use any loop construct.
Do not use ++ or -- in any recursive call argument. For example, use index + 1, instead of index++.
The replaceCells method returns the number of array entries that were updated with the replacement character.
Parameters:
array -
x - index
y - index
target -
replacement -
Returns:
number of array entries that were updated with the replacement character.