I am tasked with making a program that interfaces with a multivalue database. I receive the entire record in a string with delimeters for the values and subvalues. From there I split the data into a 2d array. Here's a snippet of one (notice the varying lengths):
0 1 2
+------------------------------------+
0 | 442 | | |
1 | C | | |
2 | | | |
3 | N | | |
4 | LAND | | |
5 | 05412300 | 05412307 | |
6 | BEARING | | |
7 | BRAND1 | BRAND2 | BRAND3 |
8 | 12 | | |
+------------------------------------+
Now I've always used ArrayLists instead of Arrays because I knew it was best practice. Now I'm wondering if using a 2d ArrayList would be beneficial as well. I've looked at some examples and I don't quite understand how to get the values when I need them. If I were to do:
String[][] cheese = {
{"chedder", "swiss", "pepperjack"},
{"sliced", "cubed", "block"}
};
String myFavorite = cheese[0][2];
myFavorite would be pepperjack, but how would I do that with a 2d ArrayList? The example's I've found haven't been too helpful for me. I do know the exact number of rows (but not columns) of data I'll be receiving and the row number will not change so maybe a regular 2d array would be best practice?