• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to make a java method derivable but have implementation?  RSS feed

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like

public abstract void CreateDemoPanel()
{
}

But this cannot be done, an abstract class cannot have implementation, I want the derived classes to use the base class method
whenever the class doesn't provide/override one.
Thanks
Jack
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jacky Luk wrote:But this cannot be done, an abstract class cannot have implementation, I want the derived classes to use the base class method
whenever the class doesn't provide/override one.


So: don't make the method abstract.

Winston
 
Java Cowboy
Sheriff
Posts: 16083
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jacky Luk wrote:... an abstract class cannot have implementation


You mean: An abstrace method cannot have an implementation.

Abstract classes can certainly contain methods with an implementation.
 
The knights of nee want a shrubbery. And a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!