26
loading...
This website collects cookies to deliver better user experience
system.out.println()
အကြောင်း ၁၀၀ ရေးရမယ့်အစား loop အခါ ၁၀၀ ပတ်ပြီးထုတ်လို့ရပါတယ်။for(initialization; condition; increment/decrement){
//code to be executed
}
system.out.println(“hello world”);
ဆို တဲ့ output တစ်ခုထွက်လာမယ်။ ပြီးတော့ နောက်ထပ် loop တစ်ခါပတ်တော့ increment value 1 တိုးခဲ့ပြီဖြစ်လို့ startpoint = 1 အဖြစ်နဲ့ condition စစ်ဆေးတယ် 10 အောက်ကငယ်နေသေးတာကြောင့် loop ဆက်သွားမယ် နောက်ထပ် system.out.println(“hello world”);
ကို ထပ်ထုတ်မယ်။ ဒီလိုနဲ့ startpoint = 9 အထိပတ်တဲ့ အခါမှာ နောက်ဆုံး 10 ကြိမ်မြောက်ရောက်တဲ့အခါမှာ startpoint < 10 မဖြစ်တော့တာမို့လို့ loop ရပ်သွားပါတယ်။for( ; ; ){
//code to be executed
}
System.out.print("*"+" ");
ဖြစ်တဲ့အတွက် * ငါးခုကို ဘေးတိုက် * * * * * ဆိုပြီး output ထွက်ပါမယ်။ သူ အောက်မှာမှ i loop ထဲမှာ println()
ရေးထားတဲ့အတွက် နောက်တစ်ကြောင်းဆင်းသွားပါမယ်။ ဒီလိုနဲ့ i loop ၅ပတ်လည်း ပြည့်ရော * * * * * ငါးကြောင်း output ထွက်လာပြီး လေးထောင့်တုံးပုံစံတွေ့ရမှာဖြစ်ပါတယ်။for(dataType variable: array_name){
//code to be executed;
}
labelName:
for(initialization; condition; increment/decrement){
//code to be executed
}
while(condition){
//code to be executed
}
int i = 1
ဆိုတာ အရင်ဆုံးကြေညာပြီး while loop ထဲမှာ ဘယ်အောက်ငယ်တဲ့ အထိဆိုပြီး condition တစ်ခုသတ်မှတ်ပေးရတယ်။ အခု i<=5 ဆိုတော့ i က 5 နဲ့ညီတဲ့ အထိ loop ပတ်မယ်ဆိုပြီး ရေးလိုက်တာဖြစ်ပါတယ်။ပြီးတော့ တန်ဖိုးတိုးသွား မယ့် i ကို output ထုတ်ပါတယ် ပြီးတော့ counter တိုးဖို့ လျော့ဖို့အတွက် increment/decrement ကိုရေးဖို့လိုပါသေးတယ်။ ဒီတော့အောက်မှာ i++;
ဆိုပြီးရေးပေးရပါတယ်။while (true) {
// code to be executed
}
do{
//code to be executed
}while(condition);