abstract interfaces

R

Razvan

Hi !






In a Java test I noticed code like:

abstract interface IDummy
{
// ......
}

This should trigger a compiler error. Interfaces are abstract
by definition. It is pointless to define an abstract one. Am I right
or not ?





Regards,
Razvan
 
M

Michael Borgwardt

Razvan said:
In a Java test I noticed code like:

abstract interface IDummy
{
// ......
}

This should trigger a compiler error. Interfaces are abstract
by definition. It is pointless to define an abstract one. Am I right
or not ?

No. Why should the compiler complain about an explicit declaration of
something that's already given implicitly? It's pointless but does no
harm and some people may consider it to improve clarity.

You're also allowed to explicitly declare interface methods public.
 
M

Mike Schilling

Razvan said:
Hi !






In a Java test I noticed code like:

abstract interface IDummy
{
// ......
}

This should trigger a compiler error. Interfaces are abstract
by definition. It is pointless to define an abstract one. Am I right
or not ?

It is pointless, but it's allowed. Likewise, interface methods can be
declared abstract and public, even though these keywords are also redundant.
I suspect one can also say:

class A
{
static interface I { }
}

even though the interface obviously has no enclosing member..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top