原创

```java

温馨提示:
本文最后更新于 2024年07月22日,已超过 254 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

```java import java.util.Random;

/* * This class provides methods for generating random numbers. * * @author Bard * @version 1.0 * @since 2023-10-27 / public class RandomNumberGenerator {

/**
 * A private instance of the Random class.
 */
private static final Random RANDOM = new Random();

/**
 * Generates a random integer between 0 (inclusive) and the specified upper bound (exclusive).
 *
 * @param upperBound The upper bound (exclusive).
 * @return A random integer between 0 and the upper bound (exclusive).
 */
public static int getRandomInteger(int upperBound) {
    return RANDOM.nextInt(upperBound);
}

/**
 * Generates a random double between 0.0 (inclusive) and 1.0 (exclusive).
 *
 * @return A random double between 0.0 and 1.0 (exclusive).
 */
public static double getRandomDouble() {
    return RANDOM.nextDouble();
}

/**
 * Generates a random boolean value.
 *
 * @return A random boolean value.
 */
public static boolean getRandomBoolean() {
    return RANDOM.nextBoolean();
}

} ```

Markdown 文件

```markdown

RandomNumberGenerator

This class provides methods for generating random numbers.

Author

Bard

Version

1.0

Since

2023-10-27

Methods

getRandomInteger(int upperBound)

Generates a random integer between 0 (inclusive) and the specified upper bound (exclusive).

Parameters:

  • upperBound: The upper bound (exclusive).

Returns:

A random integer between 0 and the upper bound (exclusive).

getRandomDouble()

Generates a random double between 0.0 (inclusive) and 1.0 (exclusive).

Returns:

A random double between 0.0 and 1.0 (exclusive).

getRandomBoolean()

Generates a random boolean value.

Returns:

A random boolean value. ```

This Markdown file provides a comprehensive documentation for the RandomNumberGenerator class, including its purpose, author, version, methods, and their descriptions.

正文到此结束