1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
/* While loop Example This Java Example shows how to use while loop to iterate in Java program. */ public class SimpleWhileLoopExample { public static void main(String[] args) { /* * Syntax of while loop is * * while( <condition> ) * <loop body> * * where <condition> is a boolean expression. Loop body is executed as long * as condition is true. * * Loop body may contain more than one statments. In that case it should be * enclosed in a block. */ int i = 0; while(i < 5) { System.out.println("i is : " + i); i++; } /* * The following code will create an infinite loop, since j < 5 will always * evaluated to true */ //int j = 0; //while(j < 5) // System.out.println("j is : " + j); } } /* Output would be i is : 0 i is : 1 i is : 2 i is : 3 i is : 4 */ |
can you post here an example of java program where there is an i/o statements, condition, looping and methods in one class only..or in one program rather..
i really do need it by saturday for my java programming subject.. i am hoping that you can help me..’
godbless
Well, I have seen this belatedly. if you still really need the same can you confirm and get it. u may also post your findings if already done
i need an example of a banking,payroll,and grading system with a do while loop and while loop
While loops are the first kind of loops that one learns. It is the most basic kind one can find.
___
I hope you help me to answer the question
5. Write an input validation loop that asks the user to enter a number in the range of
10 through 24.
i need an example of java programm with class name shape which have circle,rectangle and triangle in it