import java.util.Random; public class Ex5_2 { public static void main(String[] args) { Random rnd = new Random(); int sai, i; System.out.println("20回サイコロ振るよ。えいっ!"); for ( i=0; i<20; i++ ) { // 20回くりかえし,「i++」は「i=i+1」と同じ sai = rnd.nextInt(6) + 1; // 乱数(0,1,...,5) + 1 を生成しsaiに代入 System.out.println( i + "回目 ... " + sai ); } } }