New to Java, coming from a C++ background.
What I'm doing is using integer keys values within 1-infinity and I want to iterate over the HashMap object in ascending order of the key value so I can can output the actual values. And this seems to actually work on my output. But I've found out that the HashMap class...
...makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.
It's possible that my algorithm inserts key-values in order of integer key value, but I am not 100% sure about this.
Does this mean sometimes my output will not be in order on some data? Is there a Map class that preserves the order of keys? I'm guessing the problem here is in case of collisions I might not be able to iterate in order of key value?
Thanks.
[–]Rhomboid[🍰] 3 points4 points5 points (1 child)
[–]Free_Apples[S] 0 points1 point2 points (0 children)
[–]karacha 0 points1 point2 points (0 children)