[JAVA] Onge teacher 0 basic Java language Fifth weeks continue puzzle in prime examples

Source: Internet
Author: User





In the case of the first 50 primes in week five, continue jumps out of the question after the second cycle





This paragraph in the example:

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

Main_loop:

for (int x = 3; cnt<50; x + +)

{

for (int i=0; i<cnt; i++)

{

if (x%primes[i] = = 0)

{

Continue Main_loop;

}

}

}

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

Why the "continue Main_loop" was executed; , "x + +" in for (int x = 3; cnt<50; x + +) also executes?


*************************************************

Re-review the knowledge of the For loop, organized the following ideas:

for (int i=0;i<cnt;i++)

As long as I<CNT is established

Continue running

Continue just jumped out of this i<cnt.

i++ continue to operate;

If you are using break, just jump out of the for loop for the for (int i=0;i<cnt;i++).


[JAVA] Onge teacher 0 basic Java language Fifth weeks continue puzzle in prime examples

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.