###### tags: `Java` # 【迴圈標籤】 ### 【講義8-3:break,continue與標籤】 * 標籤名字可以自行定義,標籤就好像"幫迴圈貼便利貼" * 標籤只能搭配迴圈 --- ### **標籤 結合 continue** public static void main(String[] args) { int i = 1; int j; outer: while (i <= 3) { i++; j = 0; while (j <= 5) { j++; if (j == 4) { continue outer; } System.out.println(j); } } } Console ==> 1 2 3 1 2 3 1 2 3 --- ### **標籤 結合 breck** public static void main(String[] args) { int i = 1; int j; outer: while (i <= 3) { i++; j = 0; while (j <= 5) { j++; if (j == 4) { break outer; //跳出大迴圈 } System.out.println(j); } } } Console ==> 1 2 3
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up