SCJP 1.4, SCWCD 1.4
your eyes cannot see what your mind does not know
Originally posted by Anuj Soumya:
hii Pete
if you see page 316, the point just above what you mention ..
it says that "You cannot make a call to an instance method or an instance variable, until after the super constructor runs".
if you see your code.. you are accessing the Static variable after you are calling super()!!! which it totally legal.infact you can access any instance variable(static or not) after super has run!!
what the second point on page 316 means is that before calling super , the only variable that you can use is Static. and that also as an argument to Super() or this().
i hope i was clear![]()
regards
anuj
Originally posted by Pete Knecht:
yes, the previous constructor rule dealt with instance variables and methods, but that is not the issue here. Both the rule I'm questioning and my code example deal with static vars and methods.
SCJP 1.4, SCWCD 1.4
your eyes cannot see what your mind does not know
Originally posted by Anuj Soumya:
hii pete
Instance variables are varibale declared at class level.In your code the Static int i; is an Instance variable.that is why you are able to access it after the constructor is called.
I dont think it means that the only way to access a static varibale is thru Super() call ..as parameter!!! that would be so wrong.
![]()
Regards
anuj
Originally posted by sai purnima:
I think we can use super to call static methods but it should have a return statemnt so that a relavent super constuctor is called.Is this write else give the correct answer.One more thing we can call static methods and variables outside super also.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |