Java series (5)-process control statements and java statements

Source: Internet
Author: User

Java series (5)-process control statements and java statements

1. Ordered Structure

1. if statement

(1) legend

(2) three formats

   

A: Format 1

B: Format 2

C: Format 3

2. swich statement

Legend:

Format:

[Note] the input value can be byte, short, int, char, enumerative after JDK5, and string after JDK7;

3. Loop statements

Legend:

(1) for Loop

(2) while Loop

Legend:

Usage:

(3) do... While Loop

Legend:

Usage:

(4) differences between for and while

   

A: usage differences

[The control condition variable of the for statement cannot be used after the loop ends, but the while statement can be used again]

B: differences in understanding

[For is suitable for the determination of a range, while is suitable for loops with unclear numbers]

(5) differences between the three cycles

   

A: do... The while LOOP must be executed at least once.

B: for and while must first determine whether the condition is true before deciding whether to execute a loop

4. Control jump statements

(1) break: Meaning of Interruption

   

A: It is used in loop and switch statements, and the exit application scenario is meaningless.

B: role:

[A. Jumping out of a single loop]

[B. jump out of a multi-layer loop and use the tag statement together]

(2) continue: continue

Purpose: jump out of a loop and enter the next execution.

(3) return: return

   

A: Used to end method execution.

B: The program will not be executed in the future if return is encountered.

Related Article

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.