Is there any advantage for either approach?
Example 1:
class A { B b = new B(); }
Example 2:
class A { B b;
I think Example 2 is preferable. I think the best practice is to declare outside the constructor and initialize in the constructor.