File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Accessing the base class methods in child class.
shan raj
Ranch Hand
Joined: Dec 16, 2008
Posts: 42
posted
Aug 23, 2009 22:51:35
0
Hi,
Below is the code snippet. I want to call the func1() of class A in class C. if I use super.func1(), the class B method will be called. But I want to call func1() of class A. Can any one tell me how to call the func1() in class C in proper way.
class A { public void func1() { System.out.println("A- func1"); } } class B extends A{ public void func1() { System.out.println("B- func1"); } } class C extends B { public void func1() { // I want to call func1() of class A. } }
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
I like...
posted
Aug 23, 2009 23:17:39
0
new A(). func1();
[
Donate a pint, save a life!
] [
How to ask questions
] [
Onff-turn it on!
]
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
posted
Aug 23, 2009 23:29:28
0
There is already a discussion about that. Check
Invoke Grand-Parent Method
JDBCSupport
-
An easy to use, light-weight JDBC framework
-
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
4
posted
Aug 24, 2009 02:48:19
0
Sebastian Janisch wrote:
There is already a discussion about that. . . .
Good idea to quote that discussion. I seem to remember that thread also says such coding would be bad design.
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Accessing the base class methods in child class.
Similar Threads
static methods
redefining inherited fuctions, what gets called then ?
How to Access Object !!!!
How to call "super.super.methodName()"
Java - C++ differences in function overriding
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter