Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java If语句中的二维数组_Java_Arrays_Methods_Compiler Errors_Boolean - Fatal编程技术网

Java If语句中的二维数组

Java If语句中的二维数组,java,arrays,methods,compiler-errors,boolean,Java,Arrays,Methods,Compiler Errors,Boolean,我已经用Java创建了一个2D数组,它存储seatnumbersrow,column。我已经初始化了数组,所以所有的值都以0开头,如果后来使用另一个方法Sit占用了座位,则该坐标处的值为1 以下是初始化: int[][] seatlist= new int[FIRSTCLASS/3][3]; for (int i=0; i<= FIRSTCLASS/3; i++) { for (int j=0; j<3; j++)

我已经用Java创建了一个2D数组,它存储seatnumbersrow,column。我已经初始化了数组,所以所有的值都以0开头,如果后来使用另一个方法Sit占用了座位,则该坐标处的值为1

以下是初始化:

int[][] seatlist= new int[FIRSTCLASS/3][3];           


for (int i=0; i<= FIRSTCLASS/3; i++) 
     {  
        for (int j=0; j<3; j++) 
      { 
         seatlist[i][j]=0;

       }
    }
当我尝试编译时,我不断得到所需的数组,但int在if语句行上发现错误。我无法确定问题所在,有人能帮忙吗

提前谢谢

试试这个

Integer[][] seatlist= new Integer[FIRSTCLASS/3][3];


seatlist的声明是什么?@Code Guru我刚刚添加了它!你确定我怎样才能访问seatlist吗?假设你展示的所有代码都是从非静态方法调用的,并且seatlist是在方法之外声明的,那么就可以了。谢谢!我意识到我只是将其声明为局部变量,而不是类变量:
Integer[][] seatlist= new Integer[FIRSTCLASS/3][3];
int[FIRSTCLASS/3][3] seatlist;