What is the scope of variables declared inside a static block in java?

前端 未结 4 2020
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 03:36

Are variables declared inside a static block accessible anywhere else? What \"kind\" of member are they(ie., are they static member, too?)

4条回答
  •  -上瘾入骨i
    2020-12-14 04:16

    No, not visible outside the block. They act like local variables -- think of a static block as an anonymous function that gets called at class initialization. They are not static members.

提交回复
热议问题