摘要: 阅读全文
posted @ 2022-03-06 17:22 SmallPepsi 阅读(27) 评论(0) 推荐(0)
摘要: super注意点: 1.super调用父类的构造方法,必须在构造方法的第一个 2.super必须只能出现在子类的方法或者构造方法中 3.super和this不能同时调用构造方法Vs this: 代表的对象不同: this:本身调用者这个对象 super:代表父类对象的引用 前提 this:没有继承也 阅读全文
posted @ 2022-03-06 17:10 SmallPepsi 阅读(29) 评论(0) 推荐(0)
摘要: 比如在子类中定义这样一个方法 public void test1(){ print();//student this.print();//student super.print();//person} public void print() { System.out.println("STUDENT 阅读全文
posted @ 2022-03-06 17:08 SmallPepsi 阅读(25) 评论(0) 推荐(0)
摘要: 静态方法和非静态方法:测试类中的代码A a = new A();a.test();B b = new B();b.test();A类中的代码(静态方法)A类继承B类 public static void test() { System.out.println("A-TEST");} B类中的代码(静 阅读全文
posted @ 2022-03-06 17:08 SmallPepsi 阅读(25) 评论(0) 推荐(0)