首页
/
每日頭條
/
生活
/
super調用父類的屬性
super調用父類的屬性
更新时间:2024-10-04 21:22:25

super調用父類的屬性?public abstract class A { }public abstract class B extends A { },今天小編就來聊一聊關于super調用父類的屬性?接下來我們就一起去研究一下吧!

super調用父類的屬性(我一直認為super是指向父類)1

super調用父類的屬性

public abstract class A { }

public abstract class B extends A { }

public class C extends B { @Override public String toString() { return super.toString(); } }

public class Test { public static void main(String[] args) { C c = new C(); System.out.println(c.toString()); } }

super的含義是父類的引用嗎?

文中的super是C?是B?還是A?

這麼簡單的一個題我竟然搞錯了,深深的受到傷害。

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2024 - www.tftnews.com All Rights Reserved