How the switch switch statement does not break is executed

Source: Internet
Author: User
In Java, switch usage format:

switch (expression)
{case
constant expression 1:  statement 1;  break;
....
Case constant Expression 2:  statement 2;  break;

Default: statement;
after each case followed by a break, as long as the match to execute the corresponding statement, it will jump out of the switch and then execute the following statement, this is very good to understand.
But if the case is not followed by a break, how the program will execute it.
The following procedure, according to the number 1-7 corresponds to the output of the corresponding English words:
        From the output results, you can see that  the number 3  matches case  3 after the  first time,
Does not match the case behind,
The sequence executes the following code until the break or default is met.

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.