Solved

Calling grandfather class methods

Posted on 2004-10-23
477 Views
Last Modified: 2010-05-18
Hi everyone,

I need to call a method for a class up in the hierarchy.  That has similar meaning to super.super.method1();

parent of the parent's method1

0
Question by:The14follower
    4 Comments
     
    LVL 24

    Accepted Solution

    by:
    You can't.
    There's 3 ways of doing this:
    1) just call the inherited method,
    2) have the super class call   super.method() for you,
    3) make it static so it is accessible by class name.
    ;JOOP!
    0
     
    LVL 14

    Expert Comment

    by:Tommy Braas
    Hi The14follower,

    Unless you're able to do the first of sciuriware's suggestion, I would contend that there is a problem in your class design. You might be better off fixing the class hierarchy, rather than trying to hack your specific need.

    \t
    0
     
    LVL 24

    Expert Comment

    by:sciuriware
    May be this question is raised because it's possible in C++ which is, for that matter, a very confusing feature:

         class C : B ....

         class B : A ....

    in C:
              A::function() .....

    ;JOOP!
    0
     

    Author Comment

    by:The14follower
    Thank you very much.  That will save my time trying to do nothing.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    list of java output 2 27
    core java. isInteger methods. Finding bug. 10 49
    Help refactoring a java code 8 37
    copyEndy  challenge 15 25
    1. Package the applet into a JAR file. The applet must be in a JAR file before a certificate can be attached to it. Use the jar JDK utility. If the applet was previously referenced with the help of a codebase attribute in  tag, replace the codebase …
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now