0

For example,

WeakReference<Obj> weakObj = new WeakReference<>(obj);
Obj obj2 = weakObj.get()

In this example obj2 is strong reference type?

If yes means GC is not able to remove this reference until its parent get GCed?

Akshay
  • 752
  • 1
  • 8
  • 25
  • 2
    Yes, it's a normal reference. If you `get` the object and keep a normal reference to it, then it will not be garbage collected. – khelwood Sep 28 '20 at 08:54

2 Answers2

2

Yes

Default references are strong references

You have some more information in this other question

Alberto S.
  • 7,409
  • 6
  • 27
  • 46
2

Your weakObj is a WeakReference, and yes, get() returns a standard reference.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Mirko
  • 1,512
  • 1
  • 12
  • 19