一.封装
1.封装
2.封装错误
3.封装正确
二.private关键字:只在其设置类中使用
·提供“get变量名()”方法,用于获取成员变量的值,方法用public修饰
·提供“set变量名(参数)”方法,用于设置成员变量的值,方法用public修饰
ps:当参数为age时,setAge、getAge
三.this关键字:this修饰的变量为成员变量,在局部变量与成员变量同名时使用this
1.Student类
2.studentDemo类
一.封装
1.封装
2.封装错误
3.封装正确
二.private关键字:只在其设置类中使用
·提供“get变量名()”方法,用于获取成员变量的值,方法用public修饰
·提供“set变量名(参数)”方法,用于设置成员变量的值,方法用public修饰
ps:当参数为age时,setAge、getAge
三.this关键字:this修饰的变量为成员变量,在局部变量与成员变量同名时使用this
1.Student类
2.studentDemo类