Class scope variable vs method scope variable

后端 未结 3 369
独厮守ぢ
独厮守ぢ 2021-01-26 23:59

I know that variable scope is enclosed by a start of block { and an end of block }. If the same variable is declared within the block, then the compile

3条回答
  •  醉话见心
    2021-01-27 00:12

    Because that's the way Java was designed. The language designers could easily have made it so that it was impossible to use the same name for a local variable and an instance variable. They simply chose not to.

提交回复
热议问题