0

I need to search a Maps keys based on user input.

So in a text field the user may type "M",then hit a button marked "search" this will bring up all keys that begin with M.
Mike
Molly
Michael
Michelle
Marvin

If they type "Mi" it will bring up
Michael
Michelle
Mike

If they type "Mic" it will output
Michael
Michelle

Any tips?
Cheers.
Glen...

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JamesCherrill
0

Assuming the keys are Strings you can just loop through the keySet() testing each string with its startsWith method to select those keys that start with the desired string.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.