1234567891011121314151617181920212223242526272829 |
- class Exer03
- {
- public static void main(String[] args)
- {
- //1)对下列代码,若有输出,指出输出结果。
- int x = 4;
- int y = 1;
- if (x > 2) {
- if (y > 2) // 省略{} 只有一条语句
- System.out.println(x + y);
- // 不是语句体
-
- System.out.println("lovecoding");
- } else
- System.out.println("x is " + x);
- boolean b = true;
- //如果写成if(b=false)能编译通过吗?如果能,结果是?
- if(b = false) //建议:if(!b)
- System.out.println("a");
- else if(b)
- System.out.println("b");
- else if(!b)
- System.out.println("c");
- else
- System.out.println("d");
- }
- }
|