The foreach Loops in Java

JDK 1.5 presented another for construct, which is known as foreach loop or extended for loop. This construct empowers you to cross the complete array successively without utilizing an extra variable.

Sample Implementation:

public class Mytestarray {
public static void main(string[] args) {
double[] myarray = {0.5, 1.2, 2.2, 3.4, 4.7};
for (double i: myarray) {

This would deliver the accompanying result:
0.5 1.2 2.2 3.4 4.7

For any query or issue, feel free to discuss on