.:: ยินดีต้อนรับเข้าสู่เว็บไซต์ ::.

 

 

 

 

05540210 Java Programming Language
ภาษาจาวา
สังกัด บริหารธุรกิจ, บริหารธุรกิจ
หน่วยกิต 3 (3-0-3)
  อาจารย์ สมศักดิ์ บุตรสาคร

เนื้อหาที่เกี่ยวข้อง

 

 

 

คำสั่งวนลูป (Loops)

while (condition) {
  // loop-body;
  Statement(s);
}
Trace while Loop
int count = 0;
while (count < 2) {
  System.out.println("Welcome to Java!");
  count++;
}
Trace while Loop, cont.
int count = 0;
while (count < 2) {
  System.out.println("Welcome to Java!");
  count++;
}
Caution
ห้ามใส่ ; หลังประโยค for loop
for (int i=0; i<10; i++);
{
  System.out.println("i is " + i);
}
Caution, cont.
Similarly, the following loop is also wrong:
int i=0;
while (i < 10);
{
  System.out.println("i is " + i);
  i++;
}
In the case of the do loop, the following semicolon is needed to end the loop.
int i=0;
do {
  System.out.println("i is " + i);
  i++;
} while (i<10);