面向對象三大特徵—封裝

    封裝字段:將類的字段和屬性綁定在一起;     封裝作用:避免非法數據的訪問,保證數據的完整性; 1、訪問修飾符 public class Student { private String name; publice int age; } public 和private是常用的兩種修飾符;其中public有公開的意思,其他類可以訪問。private 有私有化的意思,只能類的內部可以使用。
相關文章
相關標籤/搜索