Skip to content

Instantly share code, notes, and snippets.

@carneeki
Last active December 10, 2015 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carneeki/4412661 to your computer and use it in GitHub Desktop.
Save carneeki/4412661 to your computer and use it in GitHub Desktop.
Demonstrate loops using while
/*
* 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