Java Tutorial 4 – Looping

I think you guys can do following:

  1. create new class
  2. now add following lines in main method

no need to import anything because we are not using scanner here.

Syntax:

while ( condition ) {

 ….to do …

}

it will first check the condition and if condition is true it run the code within the {} and again check the condition, this will continue till condition will not become false. Once it become false loop is ended.

we created here an int i and printed 1 line each time it loops.

and If u know C/C++ its going to boring for you ! because its same.

Again Doubts and suggestions  are invited.

Peace.

, , , , , ,

  1. Leave a comment

Leave a comment

Design a site like this with WordPress.com
Get started