Answers for "random object java"

1

random class in java

import java.util.Random;
public class JavaRandomClassExample
{
   public static void main(String[] args)
   {
      Random rand = new Random();
      System.out.println(rand.nextInt(10));
      System.out.println(rand.nextBoolean());
      System.out.println(rand.nextDouble());
      System.out.println(rand.nextFloat());
      System.out.println(rand.nextGaussian());
      byte[] bytes = new byte[10];
      rand.nextBytes(bytes);
      System.out.printf("[");
      for(int a = 0; a < bytes.length; a++)
      {
         System.out.printf("%d ", bytes[a]);
      }
      System.out.printf("]\n");
      System.out.println(rand.nextLong());  
      System.out.println(rand.nextInt());
      long seed = 55;
      rand.setSeed(seed);
   }
}
Posted by: Guest on November-04-2021
13

random java

import java.util.Random();
Random <name> = new Random();
<variable> = <name>.nextInt(<excuslive top limit>);
Posted by: Guest on December-28-2019
-2

random class

Random rd = new Random(); //Create an instance of Random Class
int x = rd.Next(1,50);  //Generates a random number of int datatype between 1 and 50
Console.WriteLine(x); //Print the random number on Console
Posted by: Guest on April-28-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language