Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
Ans. 1. It shouldn't result in infinite loop. Please make sure that you have a condition that will terminate the loop and that condition should be reached. 2. Make sure to use the break statement if you aspire to only look for something. Not using break will unnecessarily execute it till the end of for loop in some cases. 3. Similarly use continue to execute the loop with next iteration and bypass the rest of the code block if required. 4. Try to avoid multiple nesting of for loops. If it''s required, Make sure to use break and continue properly so as to avoid some unnecessary processing. 5. Make sure to use try catch within the loop and not outside the for loop if you expect it to continue if one of the iteration fails. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   loops   continue   break   for loop  control statements  loop statement.while loop  control statements  loop statement   architecture | ||||
Related Questions | ||||
What is the difference between for and foreach loop in java ? Which one should be used in which cases ? | ||||
What is the difference between a break statement and a continue statement? | ||||
What are the counter controlled repetitions in java ? | ||||
What are the different types of loops in Java ? | ||||
What is an infinite loop ? | ||||
What is the difference between return and continue statement ? | ||||
Why shouldn't we use string concatenation extensively or in a loop ? | ||||
Find unique values between two arrays using single for loop ? | ||||