fork download
  1. import java.util.Random;
  2.  
  3. public class RandNum
  4. {
  5.  
  6. public static void main(String[] args)
  7. {
  8. Random num;
  9. int randNum;
  10. int count = 0;
  11.  
  12. while( count <= 25 )
  13. {
  14. /*
  15.   * Need curly braces because there is more then one statement inside
  16.   * the loop.
  17.   */
  18.  
  19. num = new Random(); // Create a new Random object
  20. randNum = num.nextInt( 6 ); // Assign a value to randNum
  21.  
  22. System.out.println( randNum );
  23.  
  24.  
  25. /*
  26.   * You need to increment count each time the body of the loop
  27.   * executes so count isn't always equal to 0. If count is always
  28.   * equal to 0, you have an infinite loop that will never end.
  29.   */
  30. count++;
  31. }
  32. }
  33.  
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: class RandNum is public, should be declared in a file named RandNum.java
public class RandNum
       ^
1 error
stdout

Standard output is empty