import java.util.Random; public class Ex4_3 { public static void main(String[] args) { int x; Random rnd = new Random(); x = rnd.nextInt(2); // 0,1 のどちらかを発生する乱数 if ( x == 0 ) { System.out.println(" あたり! "); } else { System.out.println(" ぶー。はずれ "); } } }