概要
Javaで「乱数を生成する」の動作を確認してみました。以下のページを参考にしました。
実装
以下のファイルを作成しました。
JSample8_1.java
class JSample8_1{
public static void main(String[] args){
for (int i = 0 ; i < 10; i++){
System.out.println((int)Math.ceil(Math.random() * 5) + 5);
}
}
}
以下のコマンドを実行しました。
$ javac JSample8_1.java
$ java JSample8_1
6
10
9
8
7
10
6
7
7
8
まとめ
何かの役に立てばと。