fork download
  1. public class Value {
  2. public static void main(String[] args) {
  3. int x;
  4. int xLimit;
  5.  
  6. // Assign values to x and xLimit
  7. x = 1; // ค่าเริ่มต้นของ x
  8. xLimit = 5; // ค่า xLimit
  9.  
  10. // While loop
  11. while (x <= xLimit) {
  12. x++; // เพิ่มค่า x ก่อน
  13. System.out.printf("The value of x is %d\n", x);
  14. }
  15.  
  16. // Print the final value of x
  17. System.out.printf("The final value of x is %d\n", x);
  18. }
  19. }
Success #stdin #stdout 0.02s 25704KB
stdin
Standard input is empty
stdout
public class Value {
    public static void main(String[] args) {
        int x;
        int xLimit;

        // Assign values to x and xLimit
        x = 1;        // ค่าเริ่มต้นของ x
        xLimit = 5;   // ค่า xLimit

        // While loop
        while (x <= xLimit) {
            x++; // เพิ่มค่า x ก่อน
            System.out.printf("The value of x is %d\n", x);
        }

        // Print the final value of x
        System.out.printf("The final value of x is %d\n", x);
    }
}