I have a quick question I am testing out the Math.random functionality. I am trying to assign the result from the (int) (Math.random()*6)+1 for each one of the 100 boxes to an array to store the values. But I am getting an error that it is not a statement. Can someone possibly offer some guidance?
public shoes(int[] pairs)
{
System.out.println("We will roll go through the boxes 100 times and store the input for the variables");
for(int i=0; i < 100; i++)
{
//("Random Number ["+ (i+1) + "] : " + (int)(Math.random()*6));
int boxCount[i] = (int) (Math.random()*6) + 1;
}
}
You have a syntax error.
boxCounthas not been instantiated and is not a known type. You need to create theboxCountarray before you attempt to use it. See example below: