Javaのランダム()メソッド
ランダム()メソッドは、乱数、0.0 = <Math.random <1.0の範囲の乱数を返します。
文法
static double random()
パラメータ
これは、任意のパラメータを受け入れないデフォルトの方法です。
戻り値
このメソッドは、double値を返します。
例
public class Test{ public static void main(String args[]){ System.out.println( Math.random() ); System.out.println( Math.random() ); } }
上記のプログラムをコンパイルし、出力は次のようになります。
0.5444085967267008 0.7960235983184115