I want to implement in Java a matrix with custom index like this example:
country1 city1 name1 region1 population1
country2 23 5 55 ...
city2 5 9 .
name2 .
region2 .
population2
That is mat[country1][country2] should return 23.
I don’t know how I will do it.
You are likely to have to use Hashmap or HashTable with a key acting like pair to contain the two indexes:
Map<Pair<K1,K2>, V>You can take a look at that for more informations:
Map with two-dimensional key in java