มีรูปแบบดังนี้
Code: Select all
do
{
}
while(เงื่อนไข);
Code: Select all
import java.util.Scanner;
class testdowhile
{
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
int x;
do
{
System.out.print("Input number : ");
x = sc.nextInt();
if(x >= 1)
{
System.out.println("Your number is more than zero");
}
else
{
System.out.println("Your number is less than zero");
}
}
while(x != 0);
}
}