您的位置:首页 > 其它

if语句

2015-12-16 09:20 239 查看
package java151126;

/*

* If语句的几种形式

*/

public class IfDemo {

public static void main(String[] args) {

int x = 3;

if (x > 1) {

System.out.println("yes");

}

System.out.println("over");

if (x > 1) {

System.out.println("yes");

} else {

System.out.println("no");

}

// 类比三元运算符

int a = 9, b;

b = (a > 1) ? 100 : 200;

if (a > 1) {

b = 100;

} else {

b = 200;

}

}

/*

* if里只有一条语句 if (x>1) System.out.println("yes"); System.out.println("over");

*/

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: