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 JAVA structured programming

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

Share

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

This article focuses on "what is JAVA structured programming". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is JAVA structured programming"?

Catalogue

1. What is structured programming?

two。 Why use structured programming?

3. Three major structures

a. Cyclic structure

One line of code:

b. Branching structure

c. Repetitive structure

4. Function (called method in JAVA)

1. What is structured programming?

Only three structures are used in programming

You cannot use the Goto statement

In 1972, an American scientist published a paper proving that all program flows need only three major structures to complete.

two。 Why use structured programming?

Divide the code into blocks of code

Greatly improves the readability of the code

3. Three major structures A. Cyclic structure

Single thread (an execution sequence)

The code always executes the previous line and then the next line

In sequential structures, beware of empty statements that are accidentally generated.

/ / empty statement example: public class BanchTest {public static void main (String [] args) {int i; for (iDiscriminant 18) {/ / consistent with discriminant expression executor System.out.println ("adult");} else {/ / non-compound discriminant expression executor System.out.println ("minor");}

Multi-branch structure

a. Multiple-choice structure (multiple branch structures, only one is executed)

Using else if is more efficient than meeting the conditions of a single branch, and all branches will execute only one at the same time.

Package com.kfm.leiyawen.Test0831;public class BanchTest {public static void main (String [] args) {test1 ();} private static void test1 () {int age = 37; if (age)

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