To someone who doesn't know what's going on, this looks pretty strange.
First question: why does it appear the compiler allows a to be declared a second time by String a = "ccc" in the initializer block?
I venture to guess the answer to that question might resolve the second question:
why is it the value bbb that remains for the variable a as illustrated in the println from main()?
Intuitively for me, a should equal ccc in the main() method.
Im not sure, but i guess its because instance variable 'a' when declared first time, on object creation it get stored with object in heap. Inside the initialization block 'a' start referring new string 'bbb'. When declaration of 'a' appear for the second time, it gets stored in stack because it is being declared in initialization block. When initialization block ends, reference variable 'a' gets destroyed and string 'ccc' goes to string pool with no reference. The reference variable 'a' stored with object is still referring 'bbb'. So bbb gets printed in main. I think this is the reason.
is a new local variable a and in no way refers to the instance member with the same name. This also explains why the instance member has the value "bbb" when the final line of the main method is executed.
I don't always make ads but when I do they're tiny