Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Learning Code Examples

While Loops

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
While Loops package com.ack.learning; public class WhileLoops { public static void main( String[] args ) { // simple loop that goes round and around until // expression evaluations to false double index = 99999; while( index > 10 ) { System.out.println( "index has value " + index ); index /= 2; } // this would be an infinite loop... while( true ) { break; // ...if we didn't break out here } // same as while loop, but with a subtle difference. code is alway // executed before the loop iteration expression is evaluate // do..whiles are the least used looping structures do { index *= 2; System.out.println( "index has value " + index ); } while( index < 9999 ); } }