Here’s my import statement:
import java.util.*;
Here it is in main:
Random Rand = new Random() ;
Here it is in a public void method :
int a = 0 ;
while (!done)
{
int a = Rand.nextInt(10) ;
if (debug) stuff ;
if (possibles[a]==1) done = true ;
}
Here’s the error message i get:
TicTacToe.java:85: cannot find symbol
symbol : method nextInt(int)
location: class Rand
a = Rand.nextInt(10) ;
^
Whats going wrong here? it seems like i’ve done everything right to me.
You defined
Randin themainmethod and tried to use it on your public void method. It is out of scope.Try defining
Randin the same method ( and use lowercase this time)Something like:
in main:
Random Rand = new Random();In your method:
BTW use braces always even in 1 line if’s