# Math.random()

A method that returns a pseudorandom double from 0.0 up to, but not including, 1.0.

## What does **Math.random()** do in Java?

**Math.random()** — A method that returns a pseudorandom double from 0.0 up to, but not including, 1.0.

```java
class PriceCalculator {
    long roundedPrice(double price) {
        return Math.round(price);
    }
}
```

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

Updated: September 27, 2026

## In other subjects

- [Math.random() in JavaScript](https://www.ask-codey.com/glossary/math-random-javascript)

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