What is the reason why an interface method can not be static nor sychronized?

M

Michael Borgwardt

Zhao said:

Synchronization is an implementation detail and thus has no place in
an interface definition. Static methods are bound at compile time
(not sure why, but there are probably good reasons) and thus make
no sense in an interface.
 
D

Daniel Schneller

Hello!

Interfaces are generally used to pass around references to object
instances without having to know their actual type (class).
Static methods belong to the class itself, not to a particular object
instantiated from it, so there is no reason to have this in an interface.

The need for synchronisation depends on the particular implementation of
a method. Maybe they made it illegal in order to not limit the
creativity of the implementors.

Daniel
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top