運算符號 | 功能敘述 |
> | 大於 |
< | 小於 |
>= | 大於等於 |
<= | 小於等於 |
== | 等於 |
!= | 不等於 |
&& | logic AND |
|| | logic OR |
! | logic NOT |
instanceof | reference instanceof ClassName 判斷reference所指到的物件其型態是否和ClassName相容 |
public class BreakContinueExample {
public static void main(String[] argv) {
int i, j;
outerLoop:
for (i = 0; i < 100; i++) {
innerLoop:
for (j = 0; j < 100; j++) {
if (j == 50 && i == 50) {
break outerLoop;
}
}
}
System.out.println("Loop have been terminated.");
}
}
public static void main(String[] argv) {
int i, j;
outerLoop:
for (i = 0; i < 100; i++) {
innerLoop:
for (j = 0; j < 100; j++) {
if (j == 50 && i == 50) {
break outerLoop;
}
}
}
System.out.println("Loop have been terminated.");
}
}
沒有留言:
張貼留言