I have a HashMap and I\'d like to iterate they key-value pairs in a different random order each time i get the iterator. Conceptually I\'d like to \"shuffle\" the map before
Try use concurent hash map and get key by random before iteration cycle
Map map = Maps.newConcurrentMap();
map.put("1", "1");
map.put("2", "2");
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
map.remove("2");// add random key values
map.put("2", "2");
String next = iterator.next();
System.out.println("next" + next);
}
Random remove/put values can "shuffle" your map