# 2d arrays

• August 7th, 2012, 06:49 AM
jonathanfox
2d arrays
hey, I was wondering if anybody knows of any good websites or exercises for learning 2d arrays, im studying for my college repeats and one of the main things that will be on the test is a 2d array where i have to right methods for it. I cant seem to get my head around 2d arrays its really frustrating tried google it but didnt get any good tutorials on it.
kind regards
J.Fox:confused:
• August 7th, 2012, 08:22 AM
KevinWorkman
Re: 2d arrays
Think of 2d arrays as simply an array of arrays (because that's what they are). What has you confused? I'd write some example programs and play around with the concept- the best way to learn how to program is by writing code.
• August 7th, 2012, 08:32 AM
jonathanfox
Re: 2d arrays
The whole coordinate shit and how you populate certain areas on you 2d array with integers or characters, like say im doing a sudoku puzle, how the hell do i populate the grid with random numbers in 3x3 sections, stuff like that
• August 7th, 2012, 08:39 AM
Samaras
Re: 2d arrays
Here is a tutorial i am studying right now.I recommend it.Sure you can find something helpful there
The Java™ Tutorials

Good luck with test ;)
• August 7th, 2012, 09:02 AM
KevinWorkman
Re: 2d arrays
Quote:

Originally Posted by jonathanfox
The whole coordinate shit and how you populate certain areas on you 2d array with integers or characters, like say im doing a sudoku puzle, how the hell do i populate the grid with random numbers in 3x3 sections, stuff like that

Like I said, the best way to learn is by coding. Have you actually attempted to write a program that does this?

I'm not really sure what exactly you mean by coordinates. Like I said, a 2d array is just an array of arrays. So if you have array[x][y], the x index is simply accessing the top-level array (which returns another array). Then the y index is accessing that inner array, and returns whatever type you put into it.

How you display a 2d array is a different question. So to talk about coordinates, you first have to explain how you're displaying the arrays.

If you're still confused, write a program that populates a 2d array with all zeros and then changes a specific "coordinate" to a one. Where is that one? What if you move it around in the array?
• August 7th, 2012, 09:02 AM
jonathanfox
Re: 2d arrays
Cheers bud, once i know how to do 2d arrays i should be fine :)