On this page
Random
The Random class in java.util package.
Purpose
The Random class in java.util package.
Key Methods
| Method | Description |
|---|---|
key methods |
See JavaDoc for full API |
Example
Random obj = /* instantiate or obtain reference */;
// Use Random per JavaDoc
Best Practices
- Prefer
Randomfromjava.java.utilover custom reimplementations - Check thread safety requirements before sharing instances across threads
- Consult the official JavaDoc for version-specific behavior changes
- Use try-with-resources when the API implements
AutoCloseable