This is probably a 'duplicate', but I'm not sure how to search for this question...
I am initializing a non-static member variable at the declaration line:
public class A
{
private B b = new B();
...
}
I am doing it instead of initializing this variable inside the default constructor:
public class A
{
private B b;
public A()
{
b = new B();
}
...
}
Is there any difference between the two, except (perhaps) the former not being "ANSI Java" or something like that?
I am getting two different byte-codes (i.e., two different 'class' files) for the two implementations above, which leads me to believe that there might be run-time differences.
So I would like to know if I have any reason to expect anything different during run-time.
Thanks