main类型中的方法placeWalls(char [] [],int,Random)不适用于参数(char,int,Random)

时间:2018-01-31 01:22:05

标签: java

对于我的生活而言,似乎无法弄清楚为什么它会说主角中的字符而不是方法中的字符......

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);
               }
        }
   }
}

1 个答案:

答案 0 :(得分:0)

roomchar[][],这意味着room[20][10]char,而不是char[][]。你应该通过room本身。