I want to create a two-dimensional array in which I want to store records from the database. So lets say that the first is of type int and the second of type String (here I am describing just one record so basically types of db columns). How can I do it? Is an array the right data structure for that?
I want to create a two-dimensional array in which I want to store records
Share
Arrays can only contain one type. If that type happens to be
Objectthen it can storeObjectand any of its sub-types, but that doesn’t really sound like what you’re trying to accomplish here.It sounds like what you’re describing is a 2D array to store database information, with each element in the array being a column in one of the rows. This isn’t an array of records, it’s an array of column data.
Instead, just store a one-dimensional array of records, where each element of the array is a reference to the entire DB row.