dimanche 15 avril 2018

while loop in if statement in java

while loop is not working in the if statement, why its not working... and how can while loop can work in if curly braces.

public static void main(String[] args) {
    int x = 30;

    if (x < 20) {
        System.out.print("This is if statement");         
        int a = 10;
        while(a < 20) {
            System.out.print("value of x : " + a );
            a++;
            System.out.print("\n");
        } 
    } else {
        System.out.print("This is else statement");
    }        
}

Aucun commentaire:

Enregistrer un commentaire