就是只给get方法,不给set方法,如:private int a;public int getA(){return a;}private void setA(int val){// 这个方法不公开,只对内部开放 a = val;}