Question: what is the difference between for and for each loop in java?
Answer: They are basically the same, but for-each (the second one) has certain restrictions. It can be used for accessing the array elements but not for modifying them. It is not usable for loops that must iterate over multiple collections in parallel—for example, to compare the elements of two arrays.