puzzle[i][j]
For accessing specific index u have to specify its index location...
in loop it will print
puzzle[0][0]
then
puzzle[0][1]
and so on....
Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
Two ways:
1: Do some arithmetic using i and j
the first row is 1,2,3,4
The second is 5,6,7,8 which is also 4+1, 4+2, 4+3, 4+4
The third is ... 8+1, 8+2 etc see the pattern?
2: you have a nested loop that you can use to access all the array elements in order (see Majestic's post as well). You need to put 1 in the first, 2 in the second... 16 in the last. You can do this with a simple "counter" variable that starts at 1 and adds 1 each time you use it.
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
What you want is...
System.out.print(i*4+j+1);
No. What they want is to learn Java, not just get their homework done for them ready to
copy/paste. Why do you think I went to such lengths to get the OP to work that out for themself?
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073