0

Please explain java loops and how to read them...

loops explanation

17th Nov 2016, 3:41 AM
Donique Hicks
Donique Hicks - avatar
5 Answers
+ 2
there are different loops like : 1. while( the condition is true){the block of code will get excecutet} in this type of loop the condition must be true for the block of code to get excecutet so if the condition is false the loop will get terminated. 2. do{the block of code to get excecutet}(then check the condition if is true) so if the condition is false in this case the block of code will get excecutet at least one time 3.for(iterator start from zero or one;check if iterator is smaller than 100;rise the iterator by one){ excecute the block of code} and the last one is for each loop but I havent used it in my projects
17th Nov 2016, 7:07 PM
( Ķ”Ā° ĶœŹ– Ķ”Ā°)
+ 2
There is another java class called Iterator but I dont know if is still used by devs The Iterator class is to iterate on advanced data types like arraylist,linked list etc
17th Nov 2016, 7:19 PM
( Ķ”Ā° ĶœŹ– Ķ”Ā°)
+ 2
java syntax below: 1. for(int i =0; i < 100;i++){ System.out.println(i); } 2. int i = 0; do{ i++; System.out.println(i); }while(i< 100); 3. int i =0; while(i<100){ i++; System.out.println(i); }
17th Nov 2016, 7:26 PM
( Ķ”Ā° ĶœŹ– Ķ”Ā°)
0
thanks.
17th Nov 2016, 7:14 PM
Donique Hicks
Donique Hicks - avatar
0
how does it look when coded?
17th Nov 2016, 7:22 PM
Donique Hicks
Donique Hicks - avatar