Most JAVA developers are using Maps and especially HashMaps. But how many developers know how a HashMap works internally? In this post, I’ll explain the implementation of java.util.HashMap, present what’s new in the JAVA 8 implementation and talk about performance, memory and known issues when using HashMaps.
There are 4 types of references in JAVA: strong references, soft references, weak references, phantom references.
Those references differ only by the way the garbage collector manages them. If you have never heard of them, it means that you were only using the strong ones. Knowing the difference can help you, especially if you need to store temporary objects and can’t use a real caching library like eHcache or Guava.
Since those types are stongly related to the JVM garbage collector, I’ll briefly recall some information about garbage collection in JAVA and then I’ll present the differents types.