Accessing the next 3 element values in a Map knowing the key.
Posted
by Rachel
on Stack Overflow
See other posts from Stack Overflow
or by Rachel
Published on 2010-05-21T22:21:33Z
Indexed on
2010/05/21
22:40 UTC
Read the original article
Hit count: 197
I have java.util.LinkedHashMap with Integer as Key and Character as Value. I know the key of the element i want to access. In addition to the element value for the key, i also want to retrieve the next 3 element values so that i can append all the 4 element values and form a string with 4 chars. I am asking for something like how we will do in a java.util.List. Is this feasible by any means in a Map/ordered map? Please suggest any other data structure that can help me achieve this. I am using Java 6.
© Stack Overflow or respective owner