for,for each,while are used for iterations.
for loop is used if you already know how many times the loop has to executed.
while is used when you do not know the number of times loop has to executed.
for each introduced in 1.5 version is used for iterating only the elements in arrays,collections.
ex: