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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 无会

[转]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