I think that java will not initialize the a
with four values. But I'm wrong, can you please explain me how it does this? I mean what it does when a constructor called because I'm not initialize a
in constructor.
class A {
int[] a = {1,2,3,4};
A() {
a[0] = 3;
}
}
class ClassTest1 {
public static void main(String args[]) {
A b = new A();
System.out.println("hey " + b.a[0] );
System.out.println("hey " + b.a[1] );
}
}
If you explain in detail and with some external resource to understand internals, it could be better for a newbie(me).