getset方法的作用
可以访问所在类中的private的属性;
public static void main(String[] args) {
SetGetConstruct s = new SetGetConstruct("simple", 21);
s.getAge();
}
构造方法创建的对象不能访问该类中private的属性;
public class Test {
public static void main(String[] args) {
SetGetConstruct s = new SetGetConstruct("simple", 21);
System.out.println(s.age);
}
}