```java
```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.
- 本文标签: 运维
- 本文链接: https://blog.sandy1029.cloud/article/36
- 版权声明: 本文由nisan原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权