Jump to content
  • Advertisement
Sign in to follow this  
Thygrrr

[java] Keyword abstract in Interfaces

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Eclipse's extract interface tool offered to make the methods in my interface abstract. I didn't even realize that possibility, and now it got me wondering. What is the benefit of this? (I assume it's intended to allow abstract classes to "implements" (sic!) an interface, but leave the real implementation to the classes' children, which can be quite handy) Are there any disadvantages?

Share this post


Link to post
Share on other sites
Advertisement
I think interface methods are implicitly abstract, so typing 'abstract' infront of method names is optional. So I don't think there is any benefit to this, not even sure if its good style :)

Share this post


Link to post
Share on other sites
Heck... My DSL modem is "broken", so I'm back to the dial up for a while. This explains my absence from these forums, and also a possibly short answer to this post. ;)

You can declare interfaces abstract - and not only its methods - but that is redundant, no deep meaning in it, and that is no compliance with any design model (or pattern) out there.

In other words:

public abstract interface MyInterface {}


And:

public interface MyInterface {}


Are exactly the same interface. The compiler accepts both declarations, but they define the same ADT.

Son Of Cain

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!