dol*_*eng 3 java variables scope
我知道在c ++变量中有块作用域,例如,下面的代码在C++中有效
void foo(){
int a = 0;
for(int i = 0; i < 10; ++i){
int a = 1; //re-define a here.
}
Run Code Online (Sandbox Code Playgroud)
}
但是这个片段在java中不起作用,它报告"重复的局部变量a",它是否意味着java变量没有BLOCK范围?