In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly talks about "what are the sentences of Java control structure". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the sentences of Java control structure.
If structure
If (conditional expression) {/ / execute code} else if (conditional expression) {/ / execute code} else {/ / execute code}
The result of the conditional expression is true | false, which is in the form:
1. Direct Boolean variables
2. Compare the results of operators or the results of logical operators
3. In Java, non-zero numeric types or non-empty strings cannot be used to return Boolean values
Switch structure
Switch (variable name) {case literal constant 1 break;case constant / execute code break;case letter constant 2 break;default:// execute code}
1. The types of variables include integer, char and String types.
2. The literal constant in case should be consistent with the variable type: integer 3, char type'a', String type 'Hello'
3. Break, which is used to jump out of the switch structure; default, which defines the default execution code, which will be executed at the end when there is no break pop-out. In fact, neither break nor default is necessary.
4. When executing the switch statement, compare the value of the variable with the case value one by one. If it matches, the code will be executed from there.
If there is no break statement after the match, the subsequent code will be executed directly instead of the match, and will not jump out of the switch until the breakstatement is encountered or all the code has been executed.
When there is no break in switch, the default statement is executed at the end.
While structure
While (Loop condition) {/ / execute Code}
Do... While structure
Do {/ / execute Code} while (conditional expression)
For cycle structure
For (Loop variable; Loop condition; change Loop variable) {/ / execute Code}
1. The position of the three expressions of loop variable, loop condition and change loop variable cannot be changed, two; the coincidence must be retained, but the loop variable can be written outside the for, and the loop condition and the expression that changes the loop variable can be written internally.
2, loop variables, loop conditions and change loop variables can be more than one expression, the expression and the expression are separated.
Enhanced for cycle
Int [] a = {1 System.out.println (b); {1 System.out.println (b);}; for (System.out.println (b))
At this point, I believe you have a deeper understanding of "what are the sentences of the Java control structure?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.