In Java is there any way to store time ranges as key in Hashmap
? I have one HashMap
and I store times time range. For example:
I enter 0-50 range as key and for that key I will store some other objects as value. Now when I say 10 I should be able to get the corresponding value for that key.
Any value between 0-50 should get that object.
Map map = new HashMap();
map.put(0-50,"some object")
map.put(51-100,"some other object")
当我说 map.get(10)
时, 它应该能够找到“ 某些对象 ” 。 请建议如何做到这一点?