+ 1

(Help) Enhanced loop multi array, logic and syntax errors

ive been playing with the idea of multi arrays and enhanced for loops for about a week having just covered each of these ive been using google and trying to read others code can someone break it down for me and tell me any other errors ive made so i can understand better https://code.sololearn.com/c9g3Etb1ejqV/?ref=app

7th Feb 2018, 10:42 PM
MaxBanter
MaxBanter - avatar
2 Réponses
+ 15
// intended to print content of both arrays public class Program { public static void main(String[] args) { int[][] d2array = {{257,458},{2}}; /*declare 2darray ... with name d2array bcz no. can't be used in beginning of a variable name*/ for (int[] array_of_arrays:d2array){ //for variable array of arrays traverse 2darray for(int k:array_of_arrays) System.out.print(k+" "); System.out.println(); } } }
8th Feb 2018, 2:34 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
i found this works it appears to work through flattening the array (thanks to garret rowe from coderanch) https://code.sololearn.com/cuDLNCu3KZT4/?ref=app
8th Feb 2018, 1:35 AM
MaxBanter
MaxBanter - avatar