Possible Duplicate:
Instance variable initialization in java
When are initializations outside a constructor called?
Is there any difference between A1
and A2
?
class A1 {
B b = new B();
A1() {
}
}
//and
class A2 {
B b;
A2() {
b = new B();
}
}
I want to know when the class B b
does its construction if I instantiate the A1
and A2
classes.