提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用随机功能滚动骰子
public class DiceApp {//时代Java - N o w J a v a . c o m 提 供 public static void main(String[] args) { int roll; String msg = "Here are 100 random rolls of the dice:"; System.out.println(msg); for (int i=0; i<100; i++) { roll = randomInt(1, 6); System.out.print(roll + " "); } System.out.println(); } public static int randomInt(int low, int high) { int result