busybullのプロフィール

@busybull busybull
ありがとう数1
質問数2
回答数1
ベストアンサー数
1
ベストアンサー率
100%
お礼率
50%

  • 登録日2003/07/16
  • コンパイルできません。

    コマンドプロンプト上で、乱数をいくつか取得するというプログラムを作成したいのですが、コンパイル出来なくて困っています。発生させる乱数を0~900までの数字の中から0~9個のうちのいずれかの個数だけ取得するようにしたいです。j< の所に変数を記述するのはダメなのでしょうか?わかる方いましたらお願いします。 import java.util.*; public class RandomTest{ int rand; public static void main(String[] args){    Random generator = new Random();    for(int i=0; i<1; i++){     int rand = (int)(Math.random() * 10);    }    for(int j=0; j<rand; j++){     int ran = (int)(Math.random() * 1000);       System.out.println(ran);    } } }

    • ベストアンサー
    • mos21
    • Java
    • 回答数5