public class ClassSET12 {
public static void main(String[] args) {
int a[] = { 1, 2, 3, 4, 5 };
int b[] = { 6, 7, 8, 9, 10 };
int c[] = alternativeIndicesElements(a, b);
for (int d : c)
System.out.println(d);
}
public static int[] alternativeIndicesElements(int[] a, int[] b) {
int c[] = new int[a.length];
if (a.length == b.length)
for (int i = 0; i < a.length; i++)
if (i % 2 == 0)
c[i] = b[i];
else
c[i] = a[i];
return c;
}
}
What is for(d:c) and what does it do in this program and is there any other method to do this?