I’m looking for a method like:
myMap.containsKeyStartingWith("abc"); // returns true if there's a key starting with "abc" e.g. "abcd"
or
MapUtils.containsKeyStartingWith(myMap, "abc"); // same
I wondered if anyone knew of a simple way to do this
Thanks
This can be done with a standard
SortedMap:Unsorted maps (e.g.
HashMap) don’t intrinsically support prefix lookups, so for those you’ll have to iterate over all keys.