Is there a elegant way of obtaining only one Entry<K,V>
from HashMap, without iterating, if key is not known.
As order of entry of entry is not important, can we say something like
hashMapObject.get(zeroth_index);
Although I am aware that there exist no such get by index method.
If I tried approach mentioned below, it would still have to get all the entry set of the hashmap.
for(Map.Entry<String, String> entry : MapObj.entrySet()) {
return entry;
}
Suggestions are welcome.
EDIT: Please suggest any other Data Structure to suffice requirement.