How do I get the variable of one method to be a variable in another method for Java?

前端 未结 4 819
南笙
南笙 2021-01-28 22:44

Here I am trying to have my \'cash\' variable from the Player method be included in an equation in my wagerBet() method. Currently Eclipse is telling me that variable \'cash\' c

4条回答
  •  灰色年华
    2021-01-28 23:27

    The cash variable doesn't belong to any method. It is an instance member of the class. You can't access it from a static method. Make the method non-static, or pass 'cash' to it as a parameter if you only need to read its value there.

提交回复
热议问题