day08-静态static关键字修饰成员方法

This commit is contained in:
2026-05-16 15:41:47 +08:00
parent b36603b570
commit 2ccb704e31
2 changed files with 49 additions and 0 deletions

View File

@@ -16,4 +16,27 @@ public class Student {
this.name = name;
this.age = age;
}
//静态方法,只跟类有关
public static void show(){
System.out.println("学生的教室为:"+clazz);
}
//成员方法(对象方法),只跟对象有关
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}