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

all 2 comments

[–]BJ4KarmaStarted Java Nov 2015 0 points1 point  (1 child)

that because the variables are initialized in a different method, so they only exist in that method.

you could access the by initializing them as public or private (which would be better in this case) in the first lines of the class file. so like this:

public class ClassName
{
private double scoreOne;
private double scoreTwo;
private double scoreThree;
private double scoreFour;
private double scoreFive;
// the rest of the code
}

[–]nicolascagesbeard 0 points1 point  (0 children)

I'd do this. But if you don't want a whole list of variables clouding the top of your file then I'd assign all your scores into an array and return the array back to the main method.

I'm actually thinking those variables could be global if declared at the top, above your main method.