Sign in to follow this  
Thygrrr

[java] Keyword abstract in Interfaces

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this