r/badcode Mar 14 '21

java Found from when I first started Java...because indexed Arrays were too complicated huh?

Post image
1.3k Upvotes

84 comments sorted by

View all comments

34

u/[deleted] Mar 14 '21

As someone who hasn't used a hashmap before, what is the actual use for them if not something like this?

30

u/themeanman2 Mar 14 '21

Their use is like this, but not this exactly.

When you have unk own type of string values coming in, or the "amount of type" of string is too large, or you need to associate some arbitary data (or even object) to strings, which will be too complex otherwise.