Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
Aug 27, 2001



Application Security Testing: An Integral Part of DevOps

Using goto to Exit a Nested Loop

Loops (for, while, do..while) are used often in code—especially nested loops. Eventually, you need to exit the loop by using a "break" statement. However, if you are inside of a nested loop, "break" will only let you exit one level of a loop. To exit directly, you can use "goto" to a label and exit even from a deeply nested loop.

for(int i = 0; i < 100; i++)
       for(int j = 0; j < 100; j++)
          for(int k = 0; k < 100; k++)
             if(k == 15)
                goto EXIT;
          }//end k loop.
       }//end j loop.
    }//end i loop.

      // Perform any operations here.
Trong Ha
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date