如何修复:java:not语句和其他错误
我是Java新手,我需要创建一个二维布尔数组,其中的维度可以更改,然后显示布尔表,但是我遇到了一些错误 我尝试使用推荐的修复程序,但这些修复程序产生了更多错误如何修复:java:not语句和其他错误,java,arrays,Java,Arrays,我是Java新手,我需要创建一个二维布尔数组,其中的维度可以更改,然后显示布尔表,但是我遇到了一些错误 我尝试使用推荐的修复程序,但这些修复程序产生了更多错误 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner joos = new Scanner(System.in); System.out.println("Ple
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner joos = new Scanner(System.in);
System.out.println("Please enter the desired height of the grid.");
int y = joos.nextInt();
System.out.println("Please enter the desired width of the grid.");
int x = joos.nextInt();
boolean [] [] height = new boolean[y][x];
//System.out.println(y);
//System.out.println(x);
int i = 0;
int j = y*x;
for (i<=j:i++;) {
System.out.println(height[i]);
}
}
}
import java.util.Scanner;
公共班机{
公共静态void main(字符串[]args){
Scanner joos=新扫描仪(System.in);
System.out.println(“请输入所需的网格高度”);
int y=joos.nextInt();
System.out.println(“请输入所需的网格宽度”);
int x=joos.nextInt();
布尔值[][]高度=新的布尔值[y][x];
//系统输出打印项次(y);
//系统输出println(x);
int i=0;
int j=y*x;
对于(i这里有两件事:
首先,语句for(ifor(i.除了示例代码外,如果您还包括实际错误,这将非常有用。熟悉错误消息格式的人将能够立即发现该特定错误。非常感谢所有帮助,但现在我想知道如何将它们显示为网格。目前它在一行中打印false,但是否有方法在2d形状中打印它们?
for (int i = 0; i < y; i++){
for (int j = 0; j < x; j++) {
// do something now with the boolean at height[i][j]
boolean value = height[i][j];
System.out.println(value);
}
}