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");
*/
}
/*
* 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");
*/
}
相关文章推荐
- Sprint 冲刺第三阶段第3-5天
- 生活中的心理学
- 数据挖掘算法之离散化和二元化
- xcode下出现Undefined symbols for architecture arm64或者armv7: “_OBJC_CLASS_$_XXX
- AssignVar
- TCP/IP(1)-基本概念
- WebSocket
- iOS03-UIView用户交互相关的属性和方法
- js的常用函数,自定义对象,内置对象
- 携手滴滴玩跨界,vivo将“快“玩到极致
- 位运算符
- 值得推荐的C/C++框架和库 (真的很强大)
- iOS02 UILable和UITextFiled的自定义
- 《Web全栈工程师的自我修养》读书笔记
- 图像处理算法基础(六)---sobel算子自实现与opencv对比
- MySql查询时间段的方法
- OperationDemo2
- 过一天不登QQ的生活
- iOS01 计算器
- Offending RSA key in /Users/liuhang/.ssh/known_hosts:7