惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 无会

[转]java取得Linuxcpu,内存,磁盘实时信息 中国32个省的日语读法 26字母日语读法 65个源代码网站 经典面试问题【转】 An introduction to the Java 2 Platform, Enterprise Edition specification by way of BEA's WebLogic Server java 中文网址大全 Struts+Spring+Hibernate整合 自我介绍 http1.1 MYSQL初学者使用指南 候捷谈Java反射机制 jstl1.0 和 jstl1.1 区别 moiment lrc Hibernate检索策略 日本日記(十二月三日) 自定义Hibernate Dialect解决createSQLQuery时的decimal,long类型问题 hibernate 中 session 说明 java.lang.ClassCastException: org.apache.struts.action.ActionMessage 错误
[原] 子类访问基类方法
无会 · 2007-12-11 · via 博客园 - 无会

问题
类 A 为 基类
类 B 继承与类 A
类 C 继承与类 B
同时三个类中都有方法f
如何通过类 C 的对象访问 类 A 的方法???

这个问题非常容易使人产生误导为 : super.super.f();

正确的方法为:用子类对象访问基类方法.
将方法声明为static 就可以实现子类对象访问基类方法
代码实现:

 1class A {
 2 static void f() {
 3  System.out.println("hello,A");
 4 }

 5
 6}

 7
 8class B extends A {
 9
10 static void f() {
11  System.out.println("hello,B");
12 }

13
14}

15
16class TestA {
17 public static void main(String[] args) {
18  B b = new B();
19  b.f(); //JDK1.4   中结果输出   “hello,B”
20  A a = new B();
21  a.f();//JDK1.4   中结果输出   “hello,A”  
22 }

23}

24
25