I inserted some data into a Java Hashtable. If I read the data from the Hashtable, it will not return in the same order that I inserted it. How to get ordered data from a hashtable?
I use the following code to get values from a hash table:
// Get a set of the entries Set set = hsUpdateValues.entrySet(); // Get an iterator Iterator i = set.iterator(); // Display elements while (i.hasNext()) { Map.Entry me = (Map.Entry) i.next(); System.out.print( "Key : " + me.getKey() + ", Value: " + me.getValue() ); }
java sorting hashtable maps
Tester
source share