day06-面向对象特性之封装的优化_构造方法

This commit is contained in:
2026-05-10 14:59:52 +08:00
parent db5d908e6c
commit 70585d8d65
2 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package com.inmind.constructor03;
public class Demo05 {
public static void main(String[] args) {
Student s = new Student();
System.out.println(s);
System.out.println(s.getAge());
System.out.println(s.getName());
Student s1 = new Student("王五", 22);
System.out.println(s1.getAge());//22
System.out.println(s1.getName());//王五
}
}