I want to get random keys and their respective values from a Map. The idea is that a random generator would pick a key and display that value. The tricky part is that both k
if your keys are integer, or something comparable, you can use TreeMap to do that.
TreeMap treeMap = new TreeMap<>(); int key = RandomUtils.ranInt(treeMap.lastKey()); int value = treeMap.ceilingKey(key);