Keyword in Java

The for keyword in Java programming language

The for keyword in Java programming language

We will learn about the for keyword in Java programming language

In Java programming language, the for keyword is used in the for loop. The for keyword specifies a loop that executes a block of statements repeatedly until given condition (boolean expression) is true. The for loop test expression similar to if condition(based on boolean expression)

In Java language, There are two type of for loop

Syntax

The syntax of the for (classic for loop)

for(initialization; boolean Expression; increment or decrement){
statement(s) //block of statements
}
Example
int i;
for(i=0; i>=max; i++){ //boolean expression
System.out.println(i); // display statements
}

for keyword is used for loop, it executes a block of statements until the boolean expression returns true. It gets terminated when the boolean expression returns false.

Program

The real example to for keyword in for loop in java

class ForKeywordinJava{
    public static void main(String args[]){
        for(int i=1; i<10; i++){
            System.out.println("The value of i is :"+i);
                }

        }

    }

 

When the above code is compiled and executed, it will produce the following results

The value of i is :1
The value of i is :2
The value of i is :3
The value of i is :4
The value of i is :5
The value of i is :6
The value of i is :7
The value of i is :8
The value of i is :9

There are other Java language keywords that are similar to this keyword

try  in Java

Catch  in Java

implements  in java

public  in Java

static  in Java language

Volatile  in Java

Transient  in Java

Package  in Java

class  in Java

boolean  in Java

break  in Java

do  in Java

double  in Java

This  in Java

final  in Java

switch  in Java

interface  in java

extends  in Java language

 

Suggested for you

 Java language Keywords

C language Keywords

 Python language Keywords

keywords in C language

Usage of final  in Java

Usage of this  in Java

Finally in Java language

 

for loop in java   

Enhanced for loop

Nested for in Java

 

 

The while keyword in Java programming language
The do keyword in Java programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago