1. 程式人生 > 其它 >this與super的使用

this與super的使用

技術標籤:javajava

this與super

public class Person {
    public String id="身份證號";
}

public class Student extends Person {
    public String id="學號";
    public void show(){
        System.out.println(this.id);
        System.out.println(super.id);
    }
}
public class Test {
    public
static void main(String[] args) { Student student=new Student(); student.show(); } }

在這裡插入圖片描述