continue適用于任何循環(huán)控制結構中。作用是讓程序立刻跳轉到下一次循環(huán)的迭代。
在for循環(huán)中,continue語句使程序立即跳轉到更新語句。
在while或者do…while循環(huán)中,程序立即跳轉到布爾表達式的判斷語句。
continue就是循環(huán)體中一條簡單的語句:
continue;
public class Test { public static void main(String args[]) { int [] numbers = {10, 20, 30, 40, 50}; for(int x : numbers ) { if( x == 30 ) { continue; } System.out.print( x ); System.out.print("\n"); } } }
以上實例編譯運行結果如下:
10 20 40 50
2015職稱計算機考試書PowerPoint2007中 .. 定價:¥45 優(yōu)惠價:¥42 更多書籍 | |
2015年全國職稱計算機考試教材(2007模 .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |