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
The syntax of the for (classic for loop)
for(initialization; boolean Expression; increment or decrement){ statement(s) //block of statements }
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.
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
Suggested for you
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…