The basic structure of the Java programming

EDITORIAL: bloggers is to join the training career after a battle-development experience "boars", a nickname taken from the animated film "The Lion King" in the "Peng Peng", always optimistic and positive attitude towards the surrounding thing. Technical route from my full-stack Java engineer all the way toward the development of big data, data mining, and now finally have small achievements, is willing to exchange 5012 we acquired the former, you want to learn the way of help. At the same time, the bloggers also want to try to create a complete technical library, any articles related to the technical point exceptions, error, precautions are listed at the end, welcome to provide material in various ways.

  • For any errors that appear in the article please critics pointed out, must be revised.
  • Have any questions you want to discuss and study can contact me: [email protected].
  • Publish the article because of the style column-specific, self-contained and inadequacies please correct me.

The basic structure of the Java programming

Text keyword: the basic structure, sequence structure, selection structure, a cyclic structure


Structured programming has three basic configurations: sequential structure, selection structure and loop structure. Structured programming itself is a programming way and thought, and language and is not directly related. But different programming languages ​​for the expression of three basic structures are different, such as the use of keywords, the basic structure of the grammar, but the overall idea is the same. Mastered the three basic structure of the future, even if we use different programming languages, just go to learn about the differences in syntax, you can immediately grasp.

A sequence structure

Sequence structure is a particularly simple structure, in fact, normal procedures will be performed in the order from top to bottom. We just need to pay attention to what is used at the end of Java on behalf of his party, although this simple, but very important!

  • The end of each line of code you must use a semicolon, on behalf of the end
    • Semicolon can occur alone, representing an empty statement (ie doing nothing)
    • Very important: write a semicolon after selecting the structure and the loop structure will lead to the immediate end of the structure!
  • Scope braces may be used to specify a variable
    • Can only be used within the range of braces in a pair of braces variables declared within
    • Variables must be used (ie the code above code declares to be in use) after the first statement
    • Variables (above) declared, braces can be used outside the braces
  • In addition to the role of the braces lines of code as a whole, a cyclic structure selected or centralized control, and can therefore be referred to as code blocks
    • Novice do not feel free to add braces

Here Insert Picture Description

Second, the selection structure

Select the structure into the most simple logic: to be a good condition according to our needs, implementation of a code condition is satisfied, doing nothing when conditions are not satisfied, or perform another piece of code, which means that we will have a choice of execution some code.
Here Insert Picture Description

Third, the loop structure

If we need to repeatedly perform certain identical or similar code, and you can specify when they stop, you can use looping constructs. For the effect of each execution, we can make use of variables and other structures to perform custom modifications, by recycling we can use a snippet of code do a lot of repetitive work.
Here Insert Picture Description

Published 26 original articles · won praise 129 · views 60000 +

Guess you like

Origin blog.csdn.net/u012039040/article/details/103649519