Based on input from user for col1, col2, I have to show its corresponding col3 and col4 for all rows.
Number of rows is not definite(mostly unpredictable).
Should I go ahead with creating 2D arrays by defining number of rows as some number(eg:100)?
Will linkedlists make this complicated?
Could someone please let me know what needs to be done?
if you have multi-dimensional data of unpredictable size I'd really recommend you to use collections, i.e. something like LinkedLists to implement this. That doesn't make it look beautiful but at least you can deal with all kind of 2-dimensional data and you don't waste too much memory which could be the case with a large 2-dimensional array.
If the number of columns is fixed, use a List<String[]> or List<Object[]>. If not, a List<List<String>> or List<List<Object>> is the way to go. A fixed array size with a String[][] or Object[][] is bad; you need to be careful of null values and even worse, an array that is too small.
looks like number of columns are fixed in your requirement
If the number of columns is fixed, use a List<String[]> or List<Object[]>.
I agree with Rob commnets. I have another recommendation with value objects.
you can have like following way also.
List<RowVO> , RowVO consists of col1,col2,col3,col4.
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Gift giving made easy with the permaculture playing cards