• 0

[JAVA] LInkedHashMaps...please please help!


Question

Hi guys

I need to return a specific element in a hashmap.

I have a LinkedHashMap called routeLocations which contains a map of locations.

For some reason i keep getting the first element returned.

public Location getSingleLocation(int index)

{

Iterator it = routeLocations.keySet().iterator();

int i = 0 ;

while (it.hasNext())

{

if ((i) == index)

{

return routeLocations.get(it.next());

}

i++;

}

return null;

}

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.