Can someone please tell me how to print this arry with **forEach** loop
class TestVar2{
public static void main(String args[]){
int x[] = {1,2,3,5,6}; // x array
arrayPrint(x); // passing x[] into arrayPrint method
}
public static void arrayPrint(int[]... z){
for(int i[] : z){ // for each loop
System.out.print(i[0]); // print 0th position of array
}
}
}
How to print the whole array instead of one element with this loop ?