小编Shu*_*iya的帖子

线程中的异常无法读取构造函数中的值

线程“main”中的异常 java.lang.ArrayIndexOutOfBoundsException:索引 0 超出长度范围;

    import java.util.Scanner;

//import jdk.javadoc.internal.doclets.formats.html.SourceToHTMLConverter;

class checkMatrix1 {
    int row;
    int column;
    int[][] matrix = new int[row][column];

    public checkMatrix1(int row, int column) {
        this.row = row;
        this.column = column;
    }
    public checkMatrix1() {
        this.row = 3;
        this.column = 3;
    }
}

public class test{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println(" Enter Row: ");
        System.out.println(" Enter Column: ");
        int row = input.nextInt();
        int column = input.nextInt();
        checkMatrix1 matrix1 = new checkMatrix1(row, column); …
Run Code Online (Sandbox Code Playgroud)

java exception

1
推荐指数
1
解决办法
46
查看次数

标签 统计

exception ×1

java ×1