package playing_card;
import java.util.ArrayList;
import java.util.List;
public class Player {
public int id;
public String name;
List<Card> hand; 如果在这里初始化(List<Card> hand = new ArrayList<Card>();)的话调用对象的add()就不会出现空指针异常,这是为什么??Card类已经创建了
public Player(int id, String name) {
this.id = id;
this.name = name;
this.hand = new ArrayList<Card>();
}
public Player() {
}
}
ziom
相关分类