对于我的生活而言,似乎无法弄清楚为什么它会说主角中的字符而不是方法中的字符......
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random randGen = new Random();
int r=0;
int c=0;
int number;
int j = scnr.nextInt();
char[][] room = new char [r][c];
Main.placeWalls(room[20][10] ,10, randGen);
}
public static void placeWalls(char[][] room, int numberOfWalls, Random randGen) {
for (int r = 0; r<room.length;r++){
System.out.println(r);
for (int c = 0; c < room[r].length;c++){
room[r][c] = '.'; // Initialize the cell
System.out.print(room[r][c]); // Display the content of cell board
}
System.out.println(' ');
int a;
for (a = 0; a < room.length; a++) {
int number = randGen.nextInt(room.length);
System.out.println(number);
}
}
}
}
答案 0 :(得分:0)
room
是char[][]
,这意味着room[20][10]
是char
,而不是char[][]
。你应该通过room
本身。