Which Java collection class can be used to maintain the entries in the order in which they were last accessed? Choose one answer.
a. java.util.HashSet
b. java.util.LinkedHashMap
c. java.util.Hashtable
d. java.util.Vector
e. None of these
Which Java collection class can be used to maintain the entries in the order in which they were last accessed? Choose one answer.
a. java.util.HashSet
b. java.util.LinkedHashMap
c. java.util.Hashtable
d. java.util.Vector
e. None of these
java.util.LinkedHashMap can be used to maintain the entries in the order in which they were last accessed
A special constructor is provided to create a linked hash map whose order of iteration is the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order).
Other than this you can also try java.util.PriorityQueue.
A hint: take a look at the APIs of each data structure; and see if, by using only the methods listed, you can get them to do what you need (i.e. insert N elements with a specific order, query for the k-th (where 0 <= k <= N), and see if you actually get the k-th element returned according to the order you inserted them) without too much code grumbling.
This will not give you a direct answer, and you might not even get a certain answer; but in doing so (and I mean, go write some code!) you will most certainly understand how the data structures work and which one is the best for you. Worst case scenario you can go back and read the textbook and actually have a clear idea of what they are talking about.
If, on the other hand, you are more inclined towards studying the theory first, take a look at this link: it's a Java Trail on the topic.