I have Objects which need to be mapped to Integers (or primitive ints).
So for example
Object[] objects = new Object[X];
objects[2]=o1;
objects[34]=o2;
objects[126]=o3;
...
So I have a range from 0 to X for the keys but only need a few (lets say 20) mapping pairs. (The mapping is only done once and will not change)
Would it be (performance and memory-usage vise) a better idea to use a Map (and if which implementation would suite best) instead of the "large" array which is mostly unused.
The needed range might actually scale up later during development - so if it is only important for very large X that would still be interesting for me. (Currently X is 256 - so rather small)
To sum it up: I want to efficiently map Numbers to Objects in Java.