I am trying to use a random number generator for a small game I am writing. The random generator is in an external class to be called by the main.
I am getting a syntax error as indicated below and cant tell why? Any help would be great!
Code:
import java.util.Random;
public class RandomGenerator
{
Random generator = new Random(); // Error here is: Syntax error on token ";", {
for (int i = 0; i < 2; i++) // expected after this token
{
int r = generator.nextInt(2);
}
} // I also get an error here telling me to add an "}"
1 Answer