if的作用域问题 *输出1~6的随机数*

 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 }

posted @ 2018-02-05 22:07  zbgghost  阅读(281)  评论(0编辑  收藏  举报