Pergunta

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]

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top