search
HomeJavaJavagetting StartedWhat does for in java mean?

What does for in java mean?

Nov 15, 2019 am 10:04 AM
java

What does for in java mean?

for, a guide word for a loop structure

for keyword is used to specify a value in each iteration A loop that checks its condition before ending.                                                                                             (Recommended learning: java course )

for loop, making some loop structures simpler. The number of times the for loop is executed is determined before execution.

The syntax format is as follows:

for(初始化; 布尔表达式; 更新) {
    //代码语句
}

There are several instructions for the for loop:

The initialization step is performed first. A type can be declared, but one or more loop control variables can be initialized, or it can be an empty statement.

Then, detect the value of the Boolean expression. If true, the loop body is executed. If it is false, the loop terminates and execution of the statements following the loop body begins.

After executing a loop, update the loop control variables.

Detect Boolean expression again. Perform the above process in a loop.

Example

public class Test {
   public static void main(String args[]) {
 
      for(int x = 10; x < 20; x = x+1) {
         System.out.print("value of x : " + x );
         System.out.print("\n");
      }
   }
}

The compilation and running results of the above example are as follows:

value of x : 10
value of x : 11
value of x : 12
value of x : 13
value of x : 14
value of x : 15
value of x : 16
value of x : 17
value of x : 18
value of x : 19

The above is the detailed content of What does for in java mean?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.