I'm using code from Making a simple high-score system - Codecall, but I received an error while using it. The line causing the issues is inside the HighScoreManager()
class.
This is the faulty code:
public String getHighscoreString() {
String highscoreString = "";
Static int max = 10; // this line gives an error
ArrayList<Score> scores;
scores = getScores();
int i = 0;
int x = scores.size();
if (x > max) {
x = max;
}
while (i < x) {
highscoreString += (i + 1) + ".\t" + scores.get(i).getNaam() + "\t\t" + scores.get(i).getScore() + "\n";
i++;
}
return highscoreString;
}
The line Static int max = 10;
throws
not a statement
Using a lower case "s" (static
) throws
illegal start of expression
If I delete the Static
it works. I don't know weather this will have a big impact on the code or not. Using a lowercase "s" doesn't work either, and the uppercase Static
is what was from the website that had the code, so I don't know why they wrote it with an uppercase S.