In C# there is DataTable type which can be used to create multi-column structures. In java I can use nested hashmaps but its too complicated structure even if you have 3 columns. Does core java support any such structure without including any external library?
I can use multidimensional arrays but still checking for any possible option.
Java has no directly available table format. However, we can use the generics functionality to our advantage here. You can read about them here. Instantiation will look like this
Map<String, List<String>> tableMap = new HashMap<String, List<String>>();
Now, you have a 2D structure with an identifier String for every row, and the rest of the row stored as a list. You do need to choose unique identifiers for each row though, so if you are aiming to map it with a table (as you do in C#), make sure that the key of the HashMap is the primary key of the table.
I hope that helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With