Passing Variables between methods?

前端 未结 5 1843
情书的邮戳
情书的邮戳 2021-01-17 00:10

So im trying to write a simple java program for college and I\'m a complete newbie at this java stuff. I keep getting an error when I compile, \"error - could not find symbo

5条回答
  •  耶瑟儿~
    2021-01-17 00:54

    You have declared all your variables as local variables inside the main method, so they aren't in scope outside main. To have them accessible to other methods, you can do one of the following:

    • pass them to the methods as parameters
    • declare them as static class variables outside any methods, but inside the class.

提交回复
热议问题