1

I've recently realised that an interface can be declared like this in Java.

public abstract interface Foo
{
    // ... body
}

Why is this a valid syntax? Semantically, it doesn't make any sense to me (ie., an interface is already abstract, isn't it? ). Is there any difference between an interface declared with abstract and the one without?

4
  • stackoverflow.com/questions/7202616/java-abstract-interface Commented Mar 20, 2013 at 3:03
  • 3
    No difference. Every interface is implicitly abstract and this modifier is obsolete. Commented Mar 20, 2013 at 3:07
  • @Sudhanshu I agree with you that interface is implicitly abstract, though I disagree that abstract is an obsolete modifier. It is still in use to declare abstract classes which are clearly different from interfaces Commented Mar 20, 2013 at 3:11
  • I meant to say that using that modifier for an interface is obsolete. Commented Mar 20, 2013 at 4:24

1 Answer 1

4

It's not required because it's implicitly there for all interfaces. There is no difference in including it or not. It's odd to include it so I would avoid it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.