局部变量在方法,构造函数或块中声明。
由此可见, 所有块变量都是局部变量。
按照块的定义
块是平衡括号之间的一组零个或多个语句,可以在允许单个语句的任何地方使用。
所以
{ //block started} //block ended无论在块内声明什么变量,范围都限于该块。
for(int i=0; i<10;i++){ int j=0;}因此
J范围仅限于该块内部。那是循环。
for(int i=0; i<10;i++){ int j=0; //do some thing with j ---> compiler says "yes boss"}//do some thing with j ---> compiler says "Sorry boss, what is j ??"


