Why would one declare a Java interface method as abstract? Ask Question

Why would one declare a Java interface method as abstract? Ask Question

I used the "pull interface" refactoring feature of Eclipse today to create an interface based on an existing class. The dialog box offered to create all the new methods of the new interface as "abstract" methods.

What would be the benefit of that?

I thought that the fact that you were allowed to declare interface methods as abstract was a superfluous and harmless feature of the language that is not particularly encouraged.

Why would Eclipse support such a style, or why would someone voluntarily choose to do so?

Clarification: I am not asking why interface methods are abstract, that is obvious. I am asking why one would explicitly choose to mark them as abstract since if they're in an interface they are abstract anyway.

ベストアンサー1

According to the Java Language Specification, the abstract keyword for interfaces is obsolete and should no longer be used. (Section 9.1.1.1)

That said, with Java's propensity for backwards compatibility, I really doubt it will ever make a difference whether the abstract keyword is present.

おすすめ記事