封装

package com.tiedandan.oop.封装;

public class application {
public static void main(String[] args) {
student liming =new student();
liming.getName();
String b =liming.getName();
System.out.println(b);
liming.setName("黎明");
String a = liming.getName();
System.out.println(a);
//封装可起到一定的检验作用,可以过滤掉垃圾数据
liming.setAge(999);
System.out.println(liming.getAge());

}
}

package com.tiedandan.oop.封装;

public class application {
public static void main(String[] args) {
student liming =new student();
liming.getName();
String b =liming.getName();
System.out.println(b);
liming.setName("黎明");
String a = liming.getName();
System.out.println(a);
//封装可起到一定的检验作用,可以过滤掉垃圾数据
liming.setAge(999);
System.out.println(liming.getAge());

}
}

posted on 2021-11-12 13:17  张铁蛋666  阅读(34)  评论(0编辑  收藏  举报

导航