1 //测试if语句 2 public class TestIf { 3 public static void main(String[] args){ 4 double d = Math.random();//0~1之间的小数 5 int e = (int)(d*5); //[0,4] 6 //int f = 1+(int)(d*6); //[1,6] 掷色子 7 System.out.println(e); 8 /*if (e>3) {System.out.println("Big Data"); 9 10 }*/ 11 if(e<3)//不加花括号 则if的作用域只限于第一句 12 System.out.println("small"); 13 System.out.println("big data"); 14 15 16 } 17 18 }
转载于:https://www.cnblogs.com/zbgghost/p/8419598.html