this的一个作用 当前对象
class Person{
String name="小花";
int age=19;
void eat(){
System.out.println("在吃饭");
}
}
class Student extends Person{
void study(String name,int age){
System.out.println(age+"岁"+name+"在学语文");
}
}
class Student1 extends Person{
void study(String name,int age){
System.out.println(this.age+"岁"+this.name+"在学数学");
}
}
public class text18 {
public static void main(String[] args){
Student Str=new Student();
Student1 str=new Student1();
Str.study("小明", 17);
str.study("校长",18);
}
}