In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "what are the logical structure patterns in Java", with detailed content, clear steps and proper handling of details. I hope that this article "what are the logical structure patterns in Java" can help you solve your doubts? let's follow the editor's ideas to learn new knowledge.
Sequential structure
As the name implies, the sequential structure is executed in the order of the code, which is needless to say.
Branching structure
The branch structure can be subdivided into two:
If... Else... I believe we both know these two words. Translating them into Chinese is what we usually call "if". Just... So how do you use it in Java:
①: if else:
Its basic grammatical structure is as follows:
If (judgment condition) {
Statement 1
} else {
Statement 2
When the judgment condition is true, execute statement 1, otherwise execute statement 2
Example:
Import java.util.*;public class TestDemo13 {public static void main (String [] args) {Scanner scanner = new Scanner (System.in); int n = scanner.nextInt (); if (n > = 5) {System.out.println ("hello");} else {System.out.println ("hehe");}
The meaning of this code is that we enter a number. If the number is greater than or equal to 5 and meets the if condition, execute the statement in our if. If it is not satisfied, execute the following statement.
Note: the parentheses after if can only be Boolean expressions, not mathematical expressions, such as if (5
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.