Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the example of java logic control statement

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces you how the example of java logic control sentence is, the content is very detailed, interested friends can use it for reference, hope to be helpful to you.

I. Java selection structure

1. If (condition)... Else structure

Execute the statement under if when the condition = = true, otherwise execute the statement under else

2. If (condition 1)... Else if (condition 2)... Else structure (related video tutorials recommended: java video tutorials)

Execute statements under if (condition 1) when conditional 1==true; execute statements under else if (conditional n) when conditional n==true; execute statements under else when none of them are satisfied

3. Switch (operation statement). Case value structure

When the result of the operation statement = = the value of case, enter the corresponding case execution statement

Default: no matter which case you enter, as long as you don't have break, you have to enter default in the end.

Break: jump out of the current selection structure. If there is a break in the case, jump out of the switch directly.

3.1no default, no break

3.2.With default and without break

3.3.You have default and break

2. Java cycle structure

1. While (conditional) cycle, which is applicable when the number of cycles is not known, but the conditions for entering the cycle are known.

Enter the loop when the condition = = true

2. Do... While (conditional) loop, which applies when the number of cycles is not known, but the conditions for stopping the loop are known.

A statement in a value loop that jumps out of the loop until the condition = = false

3. For loop, which is suitable for knowing the number of cycles.

Format: for (define a variable; condition; operation statement) {statement to be executed per loop}

3. Return, break, continue

Return: jumps out of the current method and returns data (may not be returned)

Break: jumping out of the current logical structure

Continue: jump out of this loop and execute the next loop (none of the code following continue in this cycle is executed)

On how the example of java logic control statements is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report