package object.fz;
public class study {
//private 私有
//名字,学号,性别,学习,睡觉
public String name;
private int i
d;
private char sex;
public study() {
}
//获取这个数据
public String getName(){
return this.name;
}
//设置属性值
public void setName(String name){
this.name=name;
}
}
package object;
import object.fz.study;
//提高安全性,保护数据
//隐藏代码实现细节
//统一接口
//系统可维护添加了
public class add {
public static void main(String[] args) {
study s1=new study();
//方法名,参数列表
s1.setName("李莉");
System.out.println(s1.getName());
}
}
标签:封装,String,study,object,private,public,name From: https://www.cnblogs.com/xiaoxiaodeyan/p/17156265.html