创建私有实例成员,而不是创建公共或受保护的成员。
/* 来自 *nowjava.com - 时代Java*/ class Player { private String firstName = null; private String lastName = null; private String position = null; private int status = -1; public Player(){ } public Player(String position, int status){ this.position = position; this.status = status; } }