---
# System prepended metadata

title: 【迴圈標籤】
tags: [Java]

---


###### 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