What are the types of loops in Java, and how are they used?

Answer Posted / hr@tgksolutions.com

• In Java, for loops are used to repeatedly run statements for a specified number of times. When a programmer knows how many times to run a statement, they use a for loop.
•When some statements must run continuously until a condition is met, the while loop can be helpful. Before statements are executed in while loops, the condition is checked.
•With the exception of checking the condition after a block of statements has been executed, the do while loop is identical to the while loop. Do while loop statements should also run at least once.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a method be static?

733


What is == and === in javascript?

771


Explain when classnotfoundexception will be raised ?

795


What does java stand for?

782


Explain the purpose of garbage collection in Java?

786


how to run ecllipse with jettyserver for windows environment using batch file

1717


Is integer a class?

792


What are identifiers in java?

784


What kind of variables can a class consist?

797


Variable of the boolean type is automatically initialized as?

785


What is lifetime variable?

734


When throw keyword is used?

793


What do you understand by synchronization?

796


What exceptions occur during serialization?

847


what is deadlock? : Java thread

737