문제

Is it possible in Java to loop in the for each statement to do something similar to this:

for(String path: series[634][][3]){
   //DO Something
}

I want to specify the first and the last part of this multi-variable array and loop through the middle one.

series[const1][loopNo][const2]

도움이 되었습니까?

해결책

Multi-dimensional arrays are just arrays of arrays. You could do this:

for(String[][] pathArray1 : series[634]){
   for(String[] pathArray2 : pathArray1){
      String path = pathArray2[3];
      //DO something
   }
}

...although this is pretty hackish and ugly, and you should almost definitely use a regular old for loop for this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top