题目:编写一个程序,模拟扔硬币的结果。
import java.util.*; public class test { public static void main(String[] args) { Random rand = new Random(); int coin = rand.nextInt(); if(coin % 2 == 0) System.out.println("正面"); else System.out.println("背面"); } }
随机数是以System.currentMillionSeconds为种子计算出来的。