File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

super.super.method()

 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a way to call a method from two levels up the inheritance heirarchy (where at each level the particular method is overridden and without instantiating any of the parent classes)?
So, if we have these three classes:



Thank You
 
Rob Ross
Bartender
Posts: 2205
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.
Let me also add that if you find yourself in a situation where that's what you want to do in your code, that's a big red flag that your design is flawed.
It means, in your subclass of the "grandparent", (the middle one) you factored out some functionality that you now want to re-implement in the grandchild class (the last one). This immediately suggests to me you flatten out your hierarchy, making the bottom most class a subclass of the grandparent. There may be other refactorings as well, but this is the one that LEAPS out at me when I get asked this question.
ie, go from this:

to this:

[ February 28, 2002: Message edited by: Rob Ross ]
[ February 28, 2002: Message edited by: Rob Ross ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I'd figured. Thanks Rob.
[ February 28, 2002: Message edited by: Dirk Schreckmann ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic