There are four types of references in Java. And for each of them, the garbage collector behaves a little bit differently.
Below, I will try to explain each type of reference's characteristics and possible use cases, specifically strong, weak, soft, and phantom references.