22:25

Looping

Posted by Mitesh Patel |

/*
Here avilable For loop ,while loop and do while loop
 */


class JavaLoopExample {

    public static void main(String args[]) {
        int i;

        System.out.println("For Example");
        for (i = 1; i <= 10; i++) {
            System.out.println(i);
        }
        i = 1;

        System.out.println("While  Example");


        while (i <= 10) {
            System.out.println(i);
            i++;
        }

        i = 1;

        System.out.println("Do While  Example");

        do {
            System.out.println(i);
            i++;
        } while (i <= 10);

    }
}

0 comments:

Post a Comment

Subscribe