Home >Java >javaTutorial >What does for mean in java?

What does for mean in java?

青灯夜游
青灯夜游Original
2019-11-19 14:22:196675browse

What does for mean in java?

In java, for is a keyword and a guide word for a loop structure. The for keyword is used to specify a loop that checks its condition before the end of each iteration. The for loop makes some loop structures simpler; the number of times the for loop is executed is determined before execution.

The for loop is one of the most commonly used statements in learning Java. It is the most flexible and commonly used loop structure. Its structure is like this, you can see the picture. This is the basic structure of the for loop.

What does for mean in java?

The execution process of the for statement is:

[1] Solve the initial value expression.

[2] Solve the conditional expression. If the value is true, execute the loop body statement block, and then execute step 3; if the value is false, jump out of the loop body statement.

【3】Solve the loop process expression, and then go to step 2.

The for loop can easily replace and simplify many codes, making it easy to read and write code. For example, it used to be very troublesome for you to output a series of output statements over and over again, but now you don't need to. You only need to use a for loop to get it done. For example, let's take an example and output "Hello" 10 times on the console. If we didn't learn the loop, would you type "Hello" 10 times over and over again? But now we can easily apply the for loop and only need to complete the code like this. Look at the picture below. Isn't this much simpler?

What does for mean in java?

#The for loop is something we will often use in future studies. So we must learn this knowledge well. The for loop will also continue to deepen learning. Next, let’s use a small case to see if it is very convenient and handy. Calculate the cumulative sum of 1-100. Let's write the code through eclipse. Isn't it very simple?

What does for mean in java?

Recommended tutorial: Java tutorial

The above is the detailed content of What does for mean in java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn