Talk about the understanding of nested for loops
for nesting, let's talk about how A for loop is used.
The purpose of this is to use a for loop to output a multiplication table, which is my step-by-step understanding.
< Span style= "FONT-SIZE:14PT;" > I. syntax:
for (expression 1; Expression 2; expression 3) {
java statement;
}
Expression 1 is an initialization expression that executes first and executes only once.
Expression 2 must be an expression of type Boolean.
for loop starts execution, executes expression 1 first, and executes only once.
to determine the result of expression 2, and if true, executes the Java statement.
re-executes expression 3, based on the section of expression three, and then the result of expression 2 until expression 2
The result is false, the For loop ends.
Two. To cite an example,
This results in the following output:
you will find it to be a line style.
So I'm nesting a for loop inside this for loop, and the code
To show the results of the output:
There is no discovery, nested A for inside, will be from a line to become a face, it will be better for people to understand.
My goal is to make a multiplication table, the basic format has been, the following is the change in the data inside, the data is multiplied, so I changed the output style
(The multiplication formula in no 0 ah, the inside of the 0 to change to 1, sorry, silly, unexpectedly from 0 began to count multiplication formulas, the following change over AH)
The output is:
Basic is finished, so to modify the "J" value is OK, the code
After this modification, the appearance is:
Such a multiplication table is called out, in fact, for the nesting can be considered as a line into a polygon process.
It's easy to understand the principles. Continue next week.
Talk about the understanding of nested for loops