Home > Java > javaTutorial > control statements in java

control statements in java

高洛峰
Release: 2016-11-15 15:18:26
Original
1140 people have browsed it

Control statement

1.1 Sequential structure (the most common)

Features: The code is executed sequentially from top to bottom

1.2 Selection structure:

if Judgment statement:

switch Judgment statement:

Precautions for using the Switch statement :

1. There needs to be a break after each statement to prevent switch penetration.

2. The variables used for judgment in the switch statement can only be int, short, char, byte String (only available after jdk7)

3. The data following Case must be constant.

Advantages of switch statement: clear statement structure and fast running speed.

Disadvantages of the switch statement:

The switch that can be done by If may not be able to be done, and the if that can be done by switch can definitely be implemented.

1.3 Loop structure

While loop: first judge and execute

structure:

while (loop condition) {

loop body.

}

do while loop: execute first and then judge, the loop body will definitely be executed once.

Structure:

do{

loop body;

}while (loop condition);

for loop:

Structure:

for(;;){

Loop body

}


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template