Control Loop Structure and loop structure

Source: Internet
Author: User

Control Loop Structure and loop structure
Oc provides continue and break to control the loop structure. Of course, return can end the entire method; go... to jump

  • Use break to end the training session
For (int I = 0; I <10; I ++) {if (I = 2) // when the program loops to 2, it jumps out of the program {break ;}}
  • Use continue to end this cycle
For (int I = 0; I <10; I ++) {if (I = 2) {continue; // ignore the remaining statements in this loop} NSlog (@ "continue executing program ");}
  • Use the return end function: when return is encountered, the program ends the loop directly. Once a return statement is executed in the loop body, the return Statement will use this method.
For (int I = 0; I <10; I ++) {if (I = 2) {return; // directly jump out} NSlog (@ "remaining unexecuted programs ");}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.