集册 Java实例教程 控制对班级成员的访问

控制对班级成员的访问

欢马劈雪     最近更新时间:2020-01-02 10:19:05

443
创建私有实例成员,而不是创建公共或受保护的成员。
/* 
 来自 
*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;

    }


}