Is it (performance-wise) better to use Arrays or HashMaps when the indexes of the Array are known? Keep in mind that the \'objects array/map\' in the example is just an exam
Please, never, ever use extended if / else if / else if / else if / else if / else if cases like that. The reason I repeated it so many times is just to make you feel like your java interpreter does when it hits code-blocks like that.
As soon as you have more than one else if, either use a hashmap, or a switch / case (java 7 will let you do it on Strings, and java 6 you have to use an enum). An even better solution for read-only checking is an ImmutableMap from a framework like guava; they have highly optimized reads as they don't allow writes.