Switch select structure, switch structure

Source: Internet
Author: User
Tags case statement

Switch select structure, switch structure

Switch (expression) // expression can use byte, short, int, char {case value 1: logical statement; break; // jump out of switch statement case value 2: logical statement; break; default: // all conditions do not conform to the use of default, which is irrelevant to the location of the default logical statement; break; // The Last One can be omitted}

There are two methods to terminate a switch: 1. Execute a break to jump out of the switch. 2. Execute the switch to the end of the switch statement {}.

If the case in the switch does not have a break statement, the program continues to execute the logical statement without judging the case statement.

 

Another form of switch

Switch (expression) {case value 1: case value 2: case value 3: logical statement; break; case value 4: case value 5: case value 6: logical statement; break; default: logical statement; break ;}

 

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.