fork download
  1. // Java program to demonstrate working
  2. // of java.lang.Math.random() method
  3. import java.lang.Math;
  4.  
  5. class Gfg1 {
  6.  
  7. // driver code
  8. public static void main(String args[])
  9. {
  10. // Generate random number
  11. int rand = (int)Math.random();
  12.  
  13. // Output is different everytime this code is executed
  14. System.out.println("Random Number:" + rand);
  15. }
  16. }
Success #stdin #stdout 0.1s 48064KB
stdin
Standard input is empty
stdout
Random Number:0