Your basic requirement is met by any class that implements the Map interface ( java.util.Map ).
However, when choosing an implementation, you need to consider what operations you want to optimize for: { Insert , Delete , Random Access , Serial Access }
If you need only random access to each question (and answer), then HashMap best.
The most common use case for a dictionary, such as an application, is a list of series of entries. Thus, if you are going to show a series of questions (and answers), use the HashMap option, LinkedHashMap .
Your basic hash table functionality is provided by HashMap , and this will lead to O (1) complexity for searching, however the iteration needed to display a “series” or “listing” can be expensive.
In this case, LinkedHashMap best suit your needs as it provides a linked list bound to a base hash table; therefore, iteration or sequential access becomes inexpensive. However, the trade-off is that it makes adding and removing new entries (questions) more expensive.
bguiz source share