Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract method call

 
Gyutae Kim
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a piece of code that looks like this
abstract public class super
{
public void meth(){absMeth();}
abstract void absMeth();
}
public class sub extends super
{
protected void absMeth(){print something}
}
then when i run the meth method of sub nothing gets printed out shouldnt this work?
[ August 07, 2002: Message edited by: Gyutae Kim ]
[ August 07, 2002: Message edited by: Gyutae Kim ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gyutae,
Try this:

Hope this helps,
Michael Morris
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gyutae,
You have attempted to use the keyword "super" as a class identifier. You need to change the name of your class.
If you want to put both class declarations in the same file, then you need to make sure that only one is declared public.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then when i run the meth method of sub nothing gets printed out shouldnt this work?
Yes, Gyutae, such a structure should work. You perhaps have an error in your code. What is the code that you're trying to compile and run?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic