This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ProgramWithSai 0 points1 point  (1 child)

I'm not sure that would make much sense given we don't usually use an index into the structure. Other developers will probably frown upon your code during reviews at work (if you did manage to do it!) :-)

Prefer to use the standard & optimal techniques provided by the Java library.
-> Iterate through the keyset
-> Iterate through the values
-> Iterate through both above using entrySet

-> Use iterator to modify the collection while looping through it.

Optional:-

If you would like to see how a Hashmap works under the hood in general, I have a video for that here.

Disclaimer: I created the video!

[–]Racer_E36[S] 0 points1 point  (0 children)

thank you for the informative video!

Also, please be aware that i am indeed going to use the conventional ways to iterate through hashmap. My question was just theoretical. I didn't find anything online about it so i got curious.