Exits the current loop and exits the loop __java base

Source: Internet
Author: User

Scene:

When you import more than one piece of data through Excel (insert multiple data at once into the database), to read, parse Excel, and loop into each piece of data, before inserting a piece of data to determine whether the data already exists, if there is a continue exit the current loop, into the next cycle. For example:

Break : Jump out of the loop

for (int i = 0;i < 10;i++) {

if (i = = 2) {

Break

}

System.out.println (i);

}

continue: End this cycle

for (int i = 0;i < 10;i++) {

if (i = = 2) {

Break

}

System.out.println (i);

}

Output: 0,1,3,4,5,6,7,8,9 (not output 2) because when i==2, the execution of System.out.println (i) is skipped, directly to the next loop.

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.