day08-静态static关键字修饰成员方法
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user