3.4.1 Break ºÍ continue



ÔÚÈκÎÑ­»·ÌåÄÚ£¬¿ÉÒÔÓÃbreakºÍcontinueÀ´¿ØÖÆÑ­»·µÄÁ÷³Ì¡£ breakÓÃÀ´Í˳öÑ­»·£¬¶øcontinueÔòÓÃÀ´·ÅÆúÌåÄÚÊ£ÓàµÄÓï¾ä£¬½øÐÐÏÂÒ»ÂÖÑ­»·¡£

Case: BreakAndContinue.java
 

³ôÃûÕÑÖøµÄ "goto"

The goto keyword has been present in programming languages from the beginning.

±êÇ©ÊǺóÃæ¸ú×ÅÒ»¸öcolonµÄ±êʶ·û, ÏóÕâÑù:

label1:
ΨһÄÜ·ÅÖñêÇ©µÄµØ·½ÊÇÔÚÒ»ÌõÑ­»·Óï¾äǰ.
label1:
outer-iteration {
}
Case: LabeledFor.java
 
  1. A plain continue goes to the top of the innermost loop and continues.
  2. A labeled continue goes to the label and re-enters the loop right after that label.
  3. A break "drops out of the bottom" of the loop.
  4. A labeled break drops out of the bottom of the end of the loop denoted by the label.

Next Page