hi to all,
i knew something about marker interface i.e marker interface do not have the methods to override, but my friend said we can define our own methods. Which is the correct one my friends or me?
Please help me for this..
Thanks in advance.
Marker interfaces by definition need to be empty. Else they are just like any other interface. Of course this does not mean you cannot define your own method signatures in the interface. Only that, then it wont be technically a marker interface.
More information can be found in this FAQ article http://www.coderanch.com/how-to/java/Java-FAQ#marker
Nagacharan Lokkidi wrote:
but my friend said we can define our own methods. Which is the correct one my friends or me?
We can define, but again as maneesh said we cant call that as Marker interface!
Note:marker interface contains java.lang.Object's public methods implicitly, unless you declare explicitly!
from JLS:
If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method mm with signature ss, return type rr, and throws clause tt corresponding to each public instance method mm with signature ss, return type rr, and throws clause tt declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface.
<edit>for clarity</edit>
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
2
Please avail yourself of the search facility of this site to find the many, many, threads where this subject has been asked and exhaustively answered before. There's no really no point in rehashing all that over and over and over again.