Skip to content
Reference > Classes

Rand

Definition

Rand var = .... ;

Extends

Extended By

None

Method Summary

Owner Name Return Type Description
Rand constructor(seed, secure) Rand Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.
Rand constructor() Rand Creates a new Randomizer, used for generating random numbers
Rand constructor(seed) Rand Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.
Object getClassName() String Returns the string name of this object's class type.
Rand nextBoolean() Boolean Returns a random Boolean value.
Rand nextDouble(min, max) Double Returns a random Double between min and max values.
Rand nextGaussian() Double Return a random signed Double with a mean of 0 and standard deviation of 1.
Rand nextGuid() String Returns a random string.
Rand nextInt(min, max) Integer Returns a random Integer between min and max values.
Rand nextUUID() UUID Returns a randomly generated version 4 UUID object.
Rand shuffle(list) List Returns a new list with the values' positions randomly shuffled.
Object toJson() String Returns a string of a json representation of this object.

Method Definitions


constructor(seed,secure)

Rand rand = new Rand(Number seed, Boolean secure)

Description

Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.

Parameter Definition

Name Type Description
seed Number  seed for repeatability. If null then the seed is random
secure Boolean  if true, then secure. if null or false, then not secure

Example 1

1
2
3
Rand r = new Rand();

// r = java.util.Random@78a773fd

Example 2

1
2
3
Rand r = new Rand(1,true);

// r = java.security.SecureRandom@57c03d88

constructor()

Rand rand = new Rand()

Description

Creates a new Randomizer, used for generating random numbers


constructor(seed)

Rand rand = new Rand(Number seed)

Description

Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.

Parameter Definition

Name Type Description
seed Number  seed for repeatability. If null then the seed is random

getClassName()

String Object::getClassName()

Description

Returns the string name of this object's class type.

Example 14

1
2
3
4
Rand r = new Rand();
r.getClassName();

// r.getClassName() = Rand

nextBoolean()

Boolean Rand::nextBoolean()

Description

Returns a random Boolean value.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextBoolean();

// r.nextBoolean() = true

nextDouble(min,max)

Double Rand::nextDouble(Number min, Number max)

Description

Returns a random Double between min and max values.

Parameter Definition

Name Type Description
min Number  minimum number to be returned (inclusive). If null, then 0
max Number  maximum number to be returned (exclusive). If null, then 1

Example 1

1
2
3
4
Rand r = new Rand();
r.nextDouble(0,10);

// r.nextDouble(0,10) = 4.904304311063381

nextGaussian()

Double Rand::nextGaussian()

Description

Return a random signed Double with a mean of 0 and standard deviation of 1.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextGaussian();

// r.nextGaussian() = -1.4529385629929248

nextGuid()

String Rand::nextGuid()

Description

Returns a random string.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextGuid();

// r.nextGuid() = 56ef1a63-c046-4b98-614c-08b90772275b

nextInt(min,max)

Integer Rand::nextInt(Number min, Number max)

Description

Returns a random Integer between min and max values.

Parameter Definition

Name Type Description
min Number  minimum number to be returned (inclusive). If null, then 0
max Number  maximum number to be returned (exclusive). If null, then 1

Example 1

1
2
3
4
Rand r = new Rand();
r.nextInt(0,10);

// r.nextInt(0,10) = 1

nextUUID()

UUID Rand::nextUUID()

Description

Returns a randomly generated version 4 UUID object.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextUUID();

// r.nextUUID() = 0ca3e601-8fe7-49ed-9bf7-8745f3b38468

shuffle(list)

List Rand::shuffle(List list)

Description

Returns a new list with the values' positions randomly shuffled.

Parameter Definition

Name Type Description
list List  list of values to shuffle

Example 1

1
2
3
4
5
Rand r = new Rand();
List l = new List("a","b","c");
r.shuffle(l);

// r.shuffle(l) = [c, a, b]

toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.

Example 14

1
2
3
4
Rand r = new Rand();
r.toJson();

// r.toJson() = "java.util.Random@16aa8654"