This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
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

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

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.
I agree. Here's the link:
subject: static method in interface