- Introduction to while loop in java in Hindi
- Java Infinitive While Loop in Hindi
Contents
show
Introduction to while loop in java
जावा , while loop कई बार कार्यक्रम का एक हिस्सा पुनरावृत्त (iterate) करने के लिए उपयोग किया जाता है। यदि पुनरावृत्ति की संख्या निर्धारित नहीं है, तो लूप का उपयोग करने की सिफारिश की जाती है ।
Syntax:
while(condition){
//code to be executed
}
उदाहरण:
public class WhileExample {
public static void main(String[] args) {
int i=1;
while(i<=10){
System.out.println(i);
i++;
}
}
}
आउटपुट:
1 2 3 4 5 6 7 8 9 10
Java Infinitive While Loop
यदि आप while लूप में true पास करते हैं, तो यह infinitive while loop होगा।
Syntax:
while(true){
//code to be executed
}
उदाहरण:
public class WhileExample2 {
public static void main(String[] args) {
while(true){
System.out.println("infinitive while loop");
}
}
}
आउटपुट:
infinitive while loop infinitive while loop infinitive while loop infinitive while loop infinitive while loop ctrl+c
अब, आपको प्रोग्राम से बाहर निकलने के लिए ctrl + c दबाना होगा।