Java sharing same values in a class

后端 未结 4 502
不知归路
不知归路 2021-01-29 13:03

I have a class called Hand and another class to test it. Hand uses global variables and change their values with some methods if in class test I create

4条回答
  •  情歌与酒
    2021-01-29 13:43

    The static keyword makes the variable class-scoped, not instance-scoped. That means the same value is common for all instances of the class. A non-static member is particular to every instance of the class. Remove the static keyword and you will get the desired behavior.

提交回复
热议问题