Block variables are declared between the open and closing braces of Selection , Iteration Statements.
such as for loops , if statement.. etc
Simply that means block variable only can use within a block.
Block Local variables are not accessible from the rest of the class.
As a example if you declared a variable called i in the if statement you cannot access that variable from out of the if statement.
Compiler tells you that it cannot find variable i
important
Block variables also do not have any default values and also it cannot use without initializing.
(Try yourself to use block variable without been initialized)



No comments:
Post a Comment