Searching through Collections in Java

Posted by Click Upvote on Stack Overflow See other posts from Stack Overflow or by Click Upvote
Published on 2009-08-23T13:50:06Z Indexed on 2010/04/24 6:43 UTC
Read the original article Hit count: 283

I have a java properties file containing a key/value pair of country names and codes. I will load the contents of this file into a Collection like List or HashMap.

Then, I want users to be able to search for a country, e.g if they type 'Aus' in a textbox and click submit, then I want to search through the collection I have, containing a key/value pair of country codes/names (e.g AUS=>Australia), and return those countries which are found matching.

Is there any more efficient way of doing this, other than looping through the elements of the collection and using charAt()?

© Stack Overflow or respective owner

Related posts about java

Related posts about collections