Iam a little bit confused about what does WeakReference actually do. From what i've read let me explain:
Example1:
Integer prime = 1;
WeakReference<Integer> soft = new WeakReference<Integer>(prime);
prime = null;
In the next gc cycle prime will be collected. So far so good. But if i do this without WeakReference:
Integer prime = 1;
prime = null;
Isn't the same thing? Prime will be collected again because there is no reference.