Environment: jdk1.8
Problem: When learning HashMap, I found that the afterNodeInsertion method was called at the end of the putVal method
...
++modCount;
if (++size > threshold)
resize();
afterNodeInsertion(evict);
return null;
I searched for the afterNodeInsertion method again and found that it is called in many places, but its implementation is
void afterNodeInsertion(boolean evict) { }
An empty method? ? Want to know what this method does?
In fact, it has been mentioned in the source code that these three methods are all for inheriting
HashMap
的LinkedHashMap
class services.LinkedHashMap
中被覆盖的afterNodeInsertion
Method, used to callback to remove the earliest object placed in the Map