How does hashing of objects work in java's HashMap? I was thinking if it is more efficient to use integers as keys compared to Strings or if it does not matter.
If I have:
String str = "hello";
Object helloObject = new Object();
What is better in case of String? Use integer key:
HashMap<Integer, Object> hashes = new HashMap<Integer, Object>();
hashes.put(str.hashCode(), helloObject);
or use String key?
HashMap<String, Object> hashes = new HashMap<String, Object>();
hashes.put(str, helloObject);
What is more efficient from point of inserting and what from point of searching?