overiding in java

i would like to know, how to call a overidding method in the super class which is an abstract class. Since we cannot create instance for an abstract class, how to call a method in the super class without calling its implementation in subclass.can anyone help me?thanx in
[300 byte] By [praveenakrishnana] at [2007-9-30 0:28:00]
# 1

Hi.

There is no way to do this in general (it can be achieved to some extent for local classes, but I don't think that's what you're after).

However, are you sure you need to do this? It implies the caller is taking on responsibilities that it shouldn't have. Sounds like a flawed design somewhere...

One way to achieve something like what you're after is not to override at all (which means you lose the polymorphic effect). Rather than doing:

abstract class A {

public void doStuff() {

...

}

...

}

class B extends A {

public void doStuff() {

...

super.doStuff();

...

}

...

}

do:

abstract class A {

public void doStuff() {

...

}

...

}

class B extends A {

public void doMoreStuff() {

...

doStuff();

...

}

...

}

Rather than overriding, this leaves A.doStuff() available for clients to call as well as providing another method in B (doMoreStuff()) that has the same effect as the original overriding method.

Regards,

Lance

lance.waltona at 2007-7-16 4:58:27 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...