1、最常见的作用,跳出Switch语句:

		int k;
		switch(k)
		{
			case 1:
			{
				System.out.println(1);
			}	break;
			case 2:
			{
				System.out.println(2);
				break;
			}
		}

2、跳出语句块:

		first:
		{
			second:
			{
				third:
				{
					for(int i=0;i<3;i++)
					{
						System.out.println(i);
						if(i==2)
						{
							break second;
						}
					}
				}
				System.out.println("Second");     //不执行
			}
			System.out.println("First");
		}

3、用out标记块,跳出:

<span style="white-space:pre">		</span>first:
		{
			out:
			{
				third:
				{
					for(int i=0;i<3;i++)
					{
						System.out.println(i);
						if(i==2)
						{
							break out;
						}
					}
				}
				System.out.println("out");
			}
			System.out.println("First");
		}


相关文章:

  • 2021-05-01
  • 2021-12-22
  • 2022-12-23
  • 2021-09-21
  • 2021-06-15
  • 2021-09-24
  • 2021-12-18
  • 2021-08-12
猜你喜欢
  • 2021-04-16
  • 2021-07-16
  • 2021-04-21
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案