- Code: Select all
import java.util.Random;
class imp{
public static void main (String [] args){
Random rnum = new Random ();
int red[]=new int[7];
for(int roll=0; roll<1000; roll++){
++red[1+rnum.nextInt(6)];
}
System.out.println("Aray Num:\tTimes Shown:");
for(int face=1;face<=red.length; face++){
System.out.println(face+"\t"+red[face]);
}
}
}
I am not getting any compilation errors. When I run it doies what it is supposed to, but there is an error at the end that says:
- Code: Select all
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7
at imp.main(imp.java:14)
I cant see the error. The program does exactly what I want it to...
Thx in advance
-Phill




