local scope in Java

前端 未结 8 2018
轮回少年
轮回少年 2020-12-20 23:31

Why is it that curly braces do not define a separate local scope in Java? I was expecting this to be a feature common to the main curly brace languages (C, C++, Java, C#).<

8条回答
  •  Happy的楠姐
    2020-12-21 00:02

    It's forgotten in Java but I think Java is wrong because in ALL "block structured" languages it is authorized to do this (not only in C++ but also in Pascal, ADA, C, and so on...) and sometime we want to hide a variable of the enclosing block.

提交回复
热议问题