熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java帶標簽的break

2022-06-13   來源: Java核心技術 

  //break跳出內循環continue只結束本輪進入下一輪不跳出循環

  package test;public class ForBreak { public static void main(String[] args) {

  int i=;

  For: for (;; i++) {

  For: for (;; i+=) {

  if(i>){

  Systemoutprintln(i>:+i);

  i=;

  Systemoutprintln(i:+i);

  break;//jump out inner

  }

  if (i % == ) {

  Systemoutprintln(i%:+i);

  break For;//jump to for next;

  } else if (i % == ) {

  Systemoutprintln(i%:+i);

  break For;//jump to for next;

  }else{

  Systemoutprintln(i);

  }

  }//end for

  Systemoutprintln(for next);

  }//end for

  Systemoutprintln(for next);

  Systemoutprintln(exit);

  }}

  ==========================

  輸出

  

  

  i%:

  for next

  

  

  i>:

  i:

  for next

  

  

  i%:

  for next

  

  

  i%:

  for next

  exit


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26406.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.