基本if
if-else
多重if
if 嵌套 (特别适合连续区段选择)
字符串.equals() 方法 用于比较字符串
练习1
Math.random() 产生[0,1)随机数 (包头不包尾)产生double型
switch 语句
只能用于等值判断 switch(表达式){ (int, short, byte, char, 枚举类型,String)
case 常量1:
执行语句;
break;
case 常量2:
执行语句;
break;
....... .......
default:
执行语句;
}
循环结构
1.找到循环条件
2.找到循环
3.检查避免死循环
while循环结构
练习
do-while循环结构
for循环结构