Learning Note 5

Source: Internet
Author: User

I. Usage and attention of switch statements

Switch (expression)

{

Case: ' * * * ';

Break

Case: ' &&&;

Break

.

.

.

Default

}

The control expression type in a switch statement can only be byte, short, char, and int cannot be a string.

The switch statement first evaluates expression expression, then compares the expression with the value of the case label, once the value of the star is encountered, the program starts executing the case tag code, no longer the case after the fragment, the default label condition matches, It will not end until a break is encountered.

Second, for Loop

A For loop is a more concise loop statement

For (initialize: loop condition : loop body) When the program executes a for loop, the initialization statement for the loop is executed first, and the initialization statement executes only once before the loop starts. Each time the loop body is executed, the value of the loop condition is evaluated, and if the loop condition returns True, the loop body part is executed, and after the loop body execution finishes, the iteration statement is executed. Therefore, for a for loop, the loop condition is always executed more than the loop body, because the last execution of the loop condition returns false, and the loop body is no longer executed.

Learning Note 5

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.