In Eclipse, define a nested class

I am trying to define a nested class using Eclipse ....

public class Xxx {

    private boolean[][] grid;
    private boolean OPEN = true;
    private Site[][] s;

    class Site() {

        private int val;

        Site() {               // empty constructor


        }
    }

    public Xxx(int N) {

........
    }
.......
}

In the line defining the inner class, Site, I get an error ...

Several markers on this line - Syntax error in the token "class", @expected - Syntax error, insert "}" to complete the block

Is my syntax wrong? I do not understand the message.

+4
source share
2 answers

Remove ():

class Site {
    // ...
}
+8
source

Your class is Site()not a method, its class.Methods method is followed (), the classes are just followed{}

public class Xxx {

    private boolean[][] grid;
    private boolean OPEN = true;
    private Site[][] s;

    class Site {

        private int val;

        Site() {               // empty constructor


        }
    }

    public Xxx(int N) {

........
    }
.......
}
0
source

All Articles