- Introduction to do-while loop in java in Hindi
- Java Infinitive do-while Loop in Hindi
Contents
show
Introduction to do-while loop in java
जावा do-while loop का उपयोग कार्यक्रम के एक भाग को कई बार iterate करने के लिए किया जाता है। यदि पुनरावृत्ति की संख्या निर्धारित नहीं है और आपको कम से कम एक बार लूप को निष्पादित करना होगा, तो do-while Loop का उपयोग करने की सिफारिश की जाती है।
जावा do-while Loop को कम से कम एक बार निष्पादित किया जाता है क्योंकि loop body के बाद condition की जांच की जाती है।
Syntax:
do{
//code to be executed
}while(condition);

उदाहरण:
public class DoWhileExample {
public static void main(String[] args) {
int i=1;
do{
System.out.println(i);
i++;
}while(i<=10);
}
}
आउटपुट:
1 2 3 4 5 6 7 8 9 10
Java Infinitive do-while Loop
यदि आप do-while loop में true पास करते हैं, तो यह infinitive do-while loop होगा।
Syntax:
do{
//code to be executed
}while(true);
उदाहरण:
public class DoWhileExample2 {
public static void main(String[] args) {
do{
System.out.println("infinitive do while loop");
}while(true);
}
}
आउटपुट:
infinitive do while loop infinitive do while loop infinitive do while loop ctrl+c
अब, आपको प्रोग्राम से बाहर निकलने के लिए ctrl + c दबाना होगा।