Thanks<br />Badri
SCJP 5.0 (91%), SCBCD 1.3 (94%), SCWCD 1.4 (88%)
Originally posted by Sanjeev Kulkarni:
In the above case, you are calling peek() before 'j' is set to 1, that means, j = 0 when you call:
Thanks<br />Badri
Thanks<br />Badri
Static blocks and variables invokes (initializes) after class load in order they were declared. So you cannot access variable before you declare it. It is because it's done only once and you cant do this explicitly.
class Z {
static { j = 1; } // But doesn't j needs to be delclared before
static { i = 2; } // Initializing like i=j results in error unlike initializing like above line . Why is compiler selective?
static int i, j;
}
Thanks<br />Badri
Consider Paul's rocket mass heater. |