I’m iterating on an hashtable, concatenating the string values:
Iterator<String> it = jsonHashtableTemp.keySet().iterator();
String json = new String("[");
while (it.hasNext()) {
String s = it.next();
json = json.concat(jsonHashtableTemp.get(s).toString());
if (it.hasNext()) {
json = json.concat(", ");
}
}
json = json.concat("]");
I would to reverse the order of the iteration .
Is it possible?
You are not able to do it using
Iterator, but you could add it to a list and iterate it with a simple for like this:And this makes sense just in case you are using some ordered Hash like
LinkedHashMapas already commented.EDIT: corrected the
l.get(i)inside loop