While Edwin's post is esentially correct, it looks like you are using the SECOND index for the columns. When this code executes, does the program have both the number of rows and columns? And are there the same number of columns in each row? If so, then you probably need something more like
Notice that I've declared the array as
String. If you know all the Objects are actually Strings, you might as well do this, imo. Also, I'm assuming two variables, numRows and numCols, are declared and initialized to the correct number of rows and columns you need in the array.
Also, there is a slight problem with the logic you are using. All but one of the statements inside the for loop start with
This references only a single position in the array, so all the Strings are being placed in the same position! It seems like you really want each String in a different position, so you need to figure out how to do that.
Finally, it may actually be beneficial in this case to create a separate class to store the information you are retrieving here. From the code, it looks like you are getting records from a database. Conceivably, each record can represent an object with the columns as its attributes. (In fact, this is a fairly common way to think about database tables.) You can easily translate this into a
Java class with fields for the attributes. Then you can create a one-dimensional array that contains instances of this class. This has the advantage that, when convenient, you can store some of the data as primitive data types, and other data as other objects (such as Strings).
I won't get into further details. If you want to pursue this option, give it a shot on your own and let us know when you encounter problems. I hope this helps answer your questions and gives you some ideas to think about. Let us know how this works out.
Keep Coding!
Layne