If you were allowed to define a static method in an interface, than problems
would have hit the fan the minute you would try to invoke said method
directly from a reference to the interface itself, when you have more than
one class extending said interface with different implementations for said
method.

In other words, assuming the following definitions were allowed:

Interface Foo { static int bar(); }
Class clsFoo1 implements Foo { static int bar() { [...somecode] } }
 Class clsFoo2 implements Foo { static int bar() { [...someothercode] } }

While something like:
int x = Foo.bar();
would be completely legal from a syntax perspective, which code would have
been ran in this case?

So no static methods in interfaces, less headaches.

@Rohit: hope this answers your question.
@group: please correct me if I am wrong.


On Thu, Jun 4, 2009 at 4:59 PM, Rohit Bansal <[email protected]>wrote:


> Hello friends, could anyone help me in understanding why interfaces can not
> be made static.
>
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to