Get a value from hashtable by a part of its key

Posted by htf on Stack Overflow See other posts from Stack Overflow or by htf
Published on 2010-06-10T13:01:17Z Indexed on 2010/06/10 13:02 UTC
Read the original article Hit count: 208

Filed under:
|

Hi. Say I have a Hashtable<String, Object> with such keys and values:

apple => 1
orange => 2
mossberg => 3

I can use the standard get method to get 1 by "apple", but what I want is getting the same value (or a list of values) by a part of the key, for example "ppl". Of course it may yield several results, in this case I want to be able to process each key-value pair. So basically similar to the LIKE '%ppl%' SQL statement, but I don't want to use a (in-memory) database just because I don't want to add unnecessary complexity. What would you recommend?

© Stack Overflow or respective owner

Related posts about java

Related posts about hashtable