Types of Java Loops

Java has 4 types of loops - the while, do while, for and for each. While you can pick your favorite and use that almost everywhere, each of them has certain advantages in different applications.

You can use a debugger (a lot of IDEs have one - check out Eclipse, Netbeans, IntelliJ etc.), set up breakpoints and visualize how the following code about loops, works step-by-step.