1、true和false
if(true|false)
2、if-else
3、迭代
- while
- do-while
- for
4、Foreach
public class Test{
public static void main(String[] args) {
Random rand = new Random(47);
float f[] = new float[10];
for(int i = 0; i < 10; i++)
f[i] = rand.nextFloat();
for(float x : f)
System.out.printfln(x);
}
}
5、break、continue、return
6、goto
可以随同标签一同使用,中断循环,跳转至标签所在位置;
label1:
outer-iteration {
inner-iteration {
break; [1]
continue; [2]
continue label1; [3]
break label; [4]
}
}
[1] break中断内部迭代,回到外部迭代;
[2] continue回到内部迭代的起始处;
[3] 中断内部迭代以及外部迭代,回到label1处,进入新迭代;
[4] 中断所有迭代,并回到label1处,但不进入新迭代;