มีรูปแบบดังนี้
Code: Select all
while (เงื่อนไข)
{
}
Code: Select all
class testwhile
{
public static void main (String[]args)
{
int x = 1;
while(x <= 5)
{
System.out.println("TestWhile");
++x;
}
System.out.print("Stop");
}
}
ผลลัพธ์ที่ออกมาคือ