+ 1

I still dont understand what loop exactly mean?

14th Nov 2016, 4:35 PM
Manai Chaouki
Manai Chaouki - avatar
8 Answers
+ 9
Loops are simply good for repeating something, either infinitely or a specified number of times. Which, in programming happens pretty often.
14th Nov 2016, 5:59 PM
Keto Z
Keto Z - avatar
+ 3
a cycle that repeats itself for a certain time
14th Nov 2016, 5:26 PM
Wanderlei Borges
Wanderlei Borges - avatar
+ 3
Loops are features of programming languages that allow to execute a block of code a certain number of times (including zero and infinite times). Java has three kind of loops: for, while and do while (there is actually a fourth, the enhanced for, useful for dealing with objects). For loops are typically used when you know in advance how many times you need to execute the code block, for example when you iterate on an array of a certain length. for(i=0;i <arr.length; i++){ System.out.println (arr [i]); }//loops over the elements of the array and prints each of them The for loop consists of three parts. The first part is executed when the block start, the second is a rear condition that is checked before each iteration (when the condition is false the execution of the block ends), and the third is a piece of code that is executed at the end of each iteration. If the number of times you want to execute the code block is not pre-determined, you can use a while loop. With this kind of loop there is no limit to the number of iterations, in principle. Before each iteration a certain condition is checked, and the block is executed only if the condition evaluates to true, otherwise the block terminates. A while loop is a natural choice for an infinite loop (just choose the condition to be something like 1==1). Unless an infinite loop is what you want, make sure that the block include some code that eventually makes the condition false. i=0; while (i <10){ System.out.println(i); i++; }//prints from 0 to 9 The do while loop is a variant of the while loop in which the condition is checked after each iteration. This is useful when you want to execute the block at least once. Most programming languages which have a while loop also have a do while loop (a notable exception I know of is Groovy, a scripting language based on Java). do { System.out.println("I did it!"); //exactly once }while (1 <0);//always false Finally, loops can also be managed with the help of the break and continue operators.
14th Nov 2016, 7:53 PM
Giulio Pellitta
Giulio Pellitta - avatar
+ 3
a repeating cycle . The cycle repeats itself till the applied condition becomes false.
15th Nov 2016, 5:25 AM
Nish
Nish - avatar
0
It ll execute the instructions, until the given condition fails
18th Nov 2016, 4:40 AM
Pavankumar V
Pavankumar V - avatar
0
it is a code, time and resources saving function
20th Nov 2016, 12:24 PM
Victor Prohnitchi
Victor Prohnitchi - avatar
0
Guy its a repeater And repeats your code!
17th Dec 2016, 9:13 PM
Saeid Khajerezaei yazdi
Saeid Khajerezaei yazdi - avatar
0
loops are great solutions to prevent from manually repeating of writing unnecessary codes.
23rd Jan 2017, 7:02 AM
A Mean Ul Llah
A Mean Ul Llah - avatar