# java.util.Random

A class that produces pseudorandom values of several primitive types.

## What is **java.util.Random** in Java?

**java.util.Random** — A class that produces pseudorandom values of several primitive types.

```java
import java.util.Random;

class Dice {
    Random random = new Random();

    int roll() {
        return random.nextInt(6) + 1;
    }
}
```

Level: Apprentice · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/apprentice)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/java-util-random
