[RESOLVED] How can I use keyword “super”
Hi all,
One of the Java documentation I found that the keyword “super” can be use to call the original method from inside a method definition.
Then look at the following code,
Code:
void addNumbers(int a, int b)
{
// process 1
super.addNumbers(a, b)
// process 2
}
Let me explain it,
On the process 1, add "a" and "b" together. On the process 2 add "a" and "b" with another int value. If I do so, is it ok. Please comment me on this.
Re: How can I use keyword “super”
That wasn't exactly clear.
The super keyword is there to call the base class's version of an overridden function.
Code:
class Base
{
void foo() { ... }
}
class Derived
{
void foo() {
// something more
// now the base stuff:
super.foo();
}
Re: How can I use keyword “super”
Thanks.
By the way, in a constructor method, how can I used keyword "super".
Re: How can I use keyword “super”
super(), and it must be the first statement.
http://mindprod.com/jgloss/constructor.html
Re: How can I use keyword “super”