Where would variables initialized in initialization blocks be used? Since the scope would be resolved to the block only, these variables cannot be used outside I believe.
Where would variables initialized in initialization blocks be used? Since the scope would be resolved to the block only, these variables cannot be used outside I believe.
Larsen
Hello Larsen, I recommend you write a test program and do some 'trial-and-error' coding it is a good way to resolve such doubts.
HtH
Ikpefua
OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
Variables declared or initialized in instance block? variables declared within it's scope can be used for computations = normal to what you use local variables in a method.
I tried using such variables outside the block, say another method. But this brings up compilation error. The variable cannot be resolved outside the init block.
Where would variables initialized in initialization blocks be used? Since the scope would be resolved to the block only, these variables cannot be used outside I believe.
Larsen
Hello Larsen, I recommend you write a test program and do some 'trial-and-error' coding it is a good way to resolve such doubts.
HtH
Ikpefua
Good to see you back again, Ikpefua
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Free, earth friendly heat - from the CodeRanch trailboss