Java - Variable Scope

后端 未结 8 1536
心在旅途
心在旅途 2020-12-22 08:42

I\'m brand new to java and I have a super n00bish question. (I do have some general programming knowledge). I\'m trying to access the variable \"item\" to no avail. Can some

8条回答
  •  猫巷女王i
    2020-12-22 09:17

    You've declared item in the first do-while loop, you can't use it in the second, because when the control flow exists from the first loop, item goes out of scope.

    Also, as others suggested, proper intentation would have helped you a lot ;-)

提交回复
热议问题