Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static method in interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static method in interface" Watch "static method in interface" New topic

static method in interface

avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
Are there any reason for mehtod in the interface can't be marked static?



My Way,My Pace
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You can get an idea by trying to code it:

The compiler tells us:

So the interface method mm can't have an implementation, it is an abstract method. To give mm an implementation you must override the method in a class implementing the interface. But you cannot override static methods.

An abstract class can have a static method but its implementation must be provided by the abstract class.

[ May 25, 2004: Message edited by: Barry Gaunt ]
[ May 25, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
It is sorta covered in the JavaRanch Style Guide.
subject: static method in interface