Error: Unable to initialize main class Main Caused by: java.lang.NoClassDefFoundError: [[LInt;

Viewed 25

I am getting this error due to having another function because even if the function is empty it is showing an error n no error without it , idk what is wrong

class Main{
    public static void printSudoku(Int[][] l){
        for(int i = 0 ; i<9 ; i++){
            for( int j = 0 ; j<9; j++){
                System.out.print(l[i][j]);
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        System.out.println("Hello, World!");
        int[][] grid = { { 3, 1, 6, 5, 7, 8, 4, 9, 2 },
        { 5, 2, 9, 1, 3, 4, 7, 6, 8 },
        { 4, 8, 7, 6, 2, 9, 5, 3, 1 },
        { 2, 6, 3, 0, 1, 5, 9, 8, 7 },
        { 9, 7, 4, 8, 6, 0, 1, 2, 5 },
        { 8, 5, 1, 7, 9, 2, 6, 4, 3 },
        { 1, 3, 8, 0, 4, 7, 2, 0, 6 },
        { 6, 9, 2, 3, 5, 1, 8, 7, 4 },
        { 7, 4, 5, 0, 8, 6, 3, 1, 0 } }; 

    }
}
1 Answers

Java code is case-sensitive, which means that Int[][] is not the same as thing as int[][].

Therefore change this line:

public static void printSudoku(Int[][] l){

To have a lower case int:

public static void printSudoku(int[][] l){

When I do this, the code prints "Hello, World!" for me, with no errors.

I strongly reccomend using a piece of software called an IDE, such as eclipse or VScode, in which you can write your code. This will highlight these sorts of errors (a bit like autocorrect or spell checker) and make life much easier for you! Happy coding!

Related