I have two integers representing a specific location in a 2D array of characters, and I'm trying to write a method that will take those integers, use them as index locations in the array, and replace them with a new character, '.' (the method will then return the array to the main method).
Here's the (currently empty) method:
public static char[][] playerMoveDown(int playerPosR, int playerPosC, char[][] mazeGrid) {
}
I'm trying to do something to the effect of this:
mazeGrid[][].setCharAt(mazeGrid[playerPosR][playerPosC], '.');
But with something that works for a character array (since setCharAt only works for strings). What's a simple and easy way to this?
怎么样
mazeGrid[playerPosR][playerPosC] = '.';
What about this:
public static char[][] playerMoveDown(int playerPosR, int playerPosC, char[][] mazeGrid) {
mazeGrid[playerPosR][playerPosC] = '.';
return mazeGrid;
}
I suggest getting familiar with array syntax before proceeding further...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.