variable access outside of if statement

前端 未结 4 1830
南方客
南方客 2020-12-02 00:39

I am trying to access variable outside an if statement in java. The variable is axeMinDmg. Here is what i have but getting an error. I want minDmg = axeMi

4条回答
  •  被撕碎了的回忆
    2020-12-02 01:23

    In Java, variables are defined within a scope. Here the scope is the if block. so if you declare it outside the if block, it will be available in the enclosing method scope.

提交回复
热议问题