What causes “Can't find Symbol” and how to fix it?

前端 未结 5 1557
春和景丽
春和景丽 2020-12-19 08:06

I\'ve been trying to figure this out, I\'ve run it in different programs so it\'s definitely in the code. Probably something easy too. The error says

5条回答
  •  臣服心动
    2020-12-19 08:19

    Read the error message, love the error message.

    It takes some practice, but after awhile it's easy to see it more clearly: just read across the bold text below as a sentence :)

    error: cannot find symbol [...]

    symbol: variable password

    location: [in] class Password2.EnterButtonHandler

    There is nothing named password in that scope/context (EnterButtonHandler).

    Happy coding.


    Hint: there is a local variable with the same name in a different scope/context... perhaps it shouldn't be a local variable? See The Java Tutorial: Variables for more :)

提交回复
热议问题