Henrique Braga
1 min readJun 20, 2020

--

Hi there!

First of all, great article, thank you very much, the explanation was very easy-to-understand. Congratulations <3

Just out of curiosity, if here we use the setters to remove the reference counters for both A and B for the circular references, it would be a workaround for the drawback mentioned?

```

public class Main {

public static void main(String[] args) {

A one = new A();

B two = new B();

// Make the objects refer to each other (creates a circular reference)

one.setB(two);

two.setA(one);

one.setB(null);

two.setA(null);

one = null;

two = null;

}

}

```

--

--

Henrique Braga
Henrique Braga

Written by Henrique Braga

“If you’re not making someone else’s life better, then you’re wasting your time. Your life will become better by making other lives better.”

No responses yet