What assumptions do I need to make on my input before using HashMap? Besides assuming that it should be an even distribution? Is there some sort of input that I can't use with HashMap?
Thanks
Update - Got my answer:)
What assumptions do I need to make on my input before using HashMap? Besides assuming that it should be an even distribution? Is there some sort of input that I can't use with HashMap?
Thanks
Update - Got my answer:)
Your input obviously should match type of the HashMap. HashMap<String, Object>
here String
is type of the key and Object
is type of the value.
You can't use primitive types with hashmap like HashMap<int, double>
There are wrappers for all primitive types: HashMap<Integer, Double>
.
Also you can add null
key and value.
See also:
Understanding the workings of equals and hashCode in a HashMap