I would like to have a bi-dimensionnal array that contains only integers. The coordinates are integers as well.
The problem is:
- I don't know by advance how many cols/rows there will be.
- I would like to fill it randomly.
Example:
Assuming the first number to be 2
, placed in (3;2)
. I want to be able to add the 8
simply, for example like that: array.add(8,2,1);
_ _ _ _ _ _ _ _
_ _ _ _ => _ _ 8 _
_ _ _ 2 => _ _ _ 2
I already found something that was actually working, but it is really heavy. It is
Hashtable<Integer, Hashtable<Integer, Integer>>
Does anyone see a more sophisticate way to do it? I'm not that good with Collections.