<"question1", "1">, <"question9", "1">, <"question2", "4">, <"question5", "2"> I made a map that has this kind of data.
I want to arrange the key value in question 1, question 2, question 3. In conclusion, I want to get question 1 and the key value there.
Iterator it = paramMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
questionAnswers += pairs.getKey()+",";
}
I tried it like this, but it's not aligned. What should I do?
java map hashmap
SortedSet<String> keys = new TreeSet<String>(map.keySet());
for (String key : keys) {
String value = map.get(key);
// // do something
}
Try TreeMap. TreeMap is a data structure in which maps are arranged in a tree structure according to key values.
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
578 Understanding How to Configure Google API Key
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.