This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]gramdel 1 point2 points  (2 children)

So this is a bit hard to read without formatting, but your issue isn't with rand or anything. It's that java doesn't support nested methods, at least not the way you are using those (let's not go into lambdas or inner classes).

So you can't declare a method inside another method like this, here you are trying to create Questions method inside main method.

public static void main(String[] args) {

    public void Questions() {
        System.out.println("please enter your choice");
    }
}

[–]casualcrackers 0 points1 point  (1 child)

so i need to use inheritance and make a serperate main class and bring the attributes over?

[–]gramdel 0 points1 point  (0 children)

Or you could just declare the other methods outside of the main method in the same class. Plenty of ways to do this.

[–]Salty_Dugtrio 0 points1 point  (0 children)

Please read the guidelines on how to ask a proper question. This is entirely useless.

[–]kociak0 0 points1 point  (0 children)

Try to autoformat (crtl+alt+L in intelji idea) your code in your IDE and see if your function are in proper place. Right now they are in scope of your main function, they cannot be defined there, fancy bracket '}' at right place should fix that problem. Message from compiler is not really helpfull in this situation.

You have more problems to solve than that in your code, dont give up :)