Static vars mean it is belong to the class. Static vars get initialized when the class is loaded the first time and "this." is a object reference to the object itself. So, you can use this. on static method or static {}.
sorry, typo... i mean u can't use this. on static method or static {}. [This message has been edited by FEI NG (edited November 08, 2001).]
False The compiler will complain: the non-static variable this cannot be referenced from a static context ie this.a = ++a; ^ The answer would be true (return 11)if a in the static initializer were referenced as: Test.a = ++a; A static initializer has all access to static data and methods of its class Hope this helps rgds Jim [This message has been edited by Jim Petersen (edited November 08, 2001).]
- Jim Petersen <br />SCJP2<br />SCWCD<p>- but then again, I could be wrong...
Hi Pervez Order of initialization 1. static variables initialization. 2. static initializer block execution. (in the order of declaration, if multiple blocks found) 3. constructor header ( super or this � implicit or explicit ) 4. instance variables initialization / instance initializer block(s) execution 5. rest of the code in the constructor I would have thought a variable would have to initialize before a block so it could be used still I could stand corrected if that is not entirely accurate Hope this helps - Jim
- Jim Petersen <br />SCJP2<br />SCWCD<p>- but then again, I could be wrong...
Yes I agree static variables and initializer blocks seem to be processed in order of appearance! ie
will not compile due to illegal forward references - Thks for clearing up this doubt rgds - Jim [This message has been edited by Jim Petersen (edited November 09, 2001).]
- Jim Petersen <br />SCJP2<br />SCWCD<p>- but then again, I could be wrong...
How do they get the deer to cross at the signs? Or to read this tiny ad?