how can i call a overriden method of the super class? for example:
class A {
public void someMethod() {
// someMethod of class A
}
}
class B extends A {
public void someMethod() {
//someMethod of class B.
// How to call to the someMethod of class A
}
}
I overriden the someMethod of class A, how can i still call it from the someMethod of A?
使用super
关键字访问直接超类B中的重写方法:
super.someMethod();
您可以调用super.someMethod();
使用super
关键字
super.Methodname()
Try this
super.someMethod();
This should work.
Use super
FYI visit this link to understand with example.
You mean, still call it from the someMethod "of B"? Use:
super.someMethod()
Create the Object of A class.
A a= new A();
a.someMethod();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.