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 two variables of the Hand
class
changes in one of the variables will affect the other. How can I
make them separate ?
Class Hand
:
private static List<Card> hand = new ArrayList<Card>();
Class Test
:
Hand hand1 = new Hand();
Hand hand2 = new Hand();
If I add values to hand1
arraylist it changes also the values of hand2
arraylist.
Can I separate them?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…