You can use both to solve this problem ... an array or a hashmap. What to choose depends on your needs. Both have advantages and disadvantages. You have to compare arrays with hashmaps and then you have to decide which one fits better your needs.