Example
LinkedHashMap<Long, String> myHashMap = new LinkedHashMap<>();
myHashMap.put(new Long(1), "A Value");
Questions
- Is the key a reference or a copy?
- If I write
String aValue = myHashMap.get(new Long(1));, will I get"A Value"back? Or have I just queried for a different object (reference) and therefore I'll get an error?
HashMapsay?hashCode(), but I can't quite get the answer I need. Could point out the portion I need to read/focus on?hashCode. ThehashCodeis used to determine the index of the array the entry is stored in. If too many entries have the samehashCode, it will slow down the performance.