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