Using map.keySet()
, you can get a set of keys. Then convert this set into List
by:
List<String> l = new ArrayList<String>(map.keySet());
And then use l.get(int)
method to access keys.
PS:- source- Most concise way to convert a Set<String> to a List<String>