bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math random() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Math random() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___.out.println(Math.random());
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The random() method returns a random number between 0 and 1.
Definition and Usage
Java Math random() Method

❮ Math Methods

Example

System.out.println(Math.random());

Definition and Usage

The random() method returns a random number between 0 and 1.

This method never returns exactly 1, but it can return 0.

Syntax

public static double random()

Technical Details

Returns:A double value representing a randomly selected number between 0 and 1, excluding 1 itself.
Java version:Any

Previous

Java Math pow() Method

Next

Java Math rint() Method