Last active
December 10, 2015 09:08
-
-
Save carneeki/4412661 to your computer and use it in GitHub Desktop.
Demonstrate loops using while
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* loopWhile | |
* Demonstrate loops using the 'while' structure | |
*/ | |
class loopWhile | |
{ | |
public static void main (String[] args) | |
{ | |
int i=1; // here we create our counter called i. | |
while(i <=10) // here we say "while i is less than or equal to 10 | |
{ // do this stuf... | |
System.out.println(i); // print out i | |
i++; // it is important to 'increment' i so that the loop | |
// will eventually stop. | |
} // while(i<=10) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment