day06-面向对象特性之封装的优化_构造方法
This commit is contained in:
16
day06/src/com/inmind/constructor03/Demo05.java
Normal file
16
day06/src/com/inmind/constructor03/Demo05.java
Normal 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());//王五
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user