Math.random


使用Math.random随机值

//第一种随机值写法

 System.out.println(Math.random()); double a1 = Math.random()*100;//整数0-99取值     int c1 = (int)(Math.random()*100+1);//整数0-100取值   //第二种随机值写法 Random a2 = new Random(); int b2 = a2.nextInt(100);//整数0-99取值 while循环语句  

输出结果为:

 注释:

break终止循环 continue跳过本次循环