JavaNumberMath.random
Math.round

Math.randomNumber

Math.log

Returns a double value between 0.0 (inclusive) and 1.0 (exclusive).

문법

Math.random()

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

double
Math
dice
System
out
println
double rand = Math.random();           // 0.0 ~ 1.0 미만
int dice = (int)(Math.random() * 6) + 1; // 1~6
System.out.println(dice);