-1
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
}
}
}
如何使用此循環打印整個數組而不是一個元素?在java中使用forEach循環打印數組
迭代I []用一個簡單的for循環。對(INT J = 0;Ĵ
pringi
更多http://stackoverflow.com/questions/22059802/how-to-參見本print-all-of-arrays-with-for-loop-in-java – pringi
感謝您的回覆..但我想用foreach循環做到這一點。有沒有可能? –