Dr.COM
Dr.COM

Reputation: 51

in Eclipse, define 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) {

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

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

Multiple markers at this line - Syntax error on token "class", @ expected - Syntax error, insert "}" to complete Block

Is my syntax wrong? I don't understand the message.

Upvotes: 5

Views: 3920

Answers (2)

Kumar Abhinav
Kumar Abhinav

Reputation: 6675

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

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) {

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

Upvotes: 0

ToasteR
ToasteR

Reputation: 888

Remove the ():

class Site {
    // ...
}

Upvotes: 10

Related Questions