Keyword in Java

The do keyword in Java programming language

The do keyword in java programming language

We will learn  about the do keyword in java programming language

The do keyword is used to implement do-while loop in Java. It is used for execution of the block of statement at least one time in Java. When the boolean condition is executed, if the condition is true, the loop executes again. But, if boolean condition is false, the loop exits.

Remarks

  • the body of do loop is always executed at least ones whether the condition specified with the while keyword is true or false
  • The semicolon after the condition expressions is always required
  • The do keyword may not used as an identifier
  • you cannot declare a variable or class with this name of Java program
Syntax

Syntax of do statement

do
{
<statements>
}
while(condition)

The do loop iterates a block of statements with the while loop

do{
i++;
}while(condition) // condition is test i<MaxNum
Example
class DoKeywordinJava{
public static void main(String args[]){
int i=0;
do{
System.out.println("i value is :"+i);
i++;

}while(i<10);
}

}

 

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

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

 

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

try keyword in Java

Catch keyword in Java

implements keyword in java

public Key words in Java

static keyword in Java language

Volatile Keyword in Java

Transient keyword in Java

Package keyword in Java

class keyword in Java

boolean keyword in Java

break keyword in Java

do keyword in Java

double keyword in Java

This keyword in Java

final keyword in Java

switch keyword in Java

interface keyword in java

extends keyword in Java language

 

Suggested for you

 Java language Keywords

C language Keywords

 Python language Keywords

keywords in C language

Usage of final keyword in Java

Usage of this keyword in Java

Finally keyword in Java language

The for keyword in Java programming language
The if 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