RandomUtil

RandomUtil class is used to generate pseudo-random numbers in java. An instance of this class is thread-safe. The instance of this class is however cryptographically insecure. This class provides various method calls to generate different random data types such as float, double, int.

/**
 * Write your code here
 * For example a random condition that returns true or false and output them to a different output port
 */
var random = RandomUtil.create(); // create a Random instance
return random.nextBoolean(); // return random boolean (true/false)
return random.nextInt(); // return random Integer
return random.nextDouble(); // return random Double
return random.nextLong();
return random.nextFloat();
return random.nextGaussian();
  • nextGaussian();

Returns the next pseudorandom Gaussian distributed double number with mean 0.0 and standard deviation 1.0.

  • nextInt();

Returns the next Integer number.

  • nextDouble();

Returns the next double number.

  • nextBoolean();

Returns the next Boolean value.

  • nextLong();

Returns the next Long number

Last updated