Saved Bookmarks
| 1. |
Can You Sort Hashmap In Java? |
|
Answer» No, you cannot sort a HashMap because unlike List it is not an ordered COLLECTION. Albeit, you can sort CONTENTS of HashMap by keys, values or by entries by SORTING and then storing the RESULT into an ordered map e.g. LinkedHashMap or a sorted map e.g. TreeMap. No, you cannot sort a HashMap because unlike List it is not an ordered collection. Albeit, you can sort contents of HashMap by keys, values or by entries by sorting and then storing the result into an ordered map e.g. LinkedHashMap or a sorted map e.g. TreeMap. |
|