Before Java 5, they were a substitute for class level annotations.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
You are probably right about "what is the use?" There is more information about marker interfaces in these FAQ, with another useful link. You will have to scroll down the FAQ a bit to find marker interfaces (also called tagging interfaces).
Joined: Dec 16, 2007
I still dont get it. To quote java faqs
Marker interfaces are a misuse of interfaces, and should be avoided.
Originally posted by rakesh sugirtharaj: I still dont get it. To quote java faqs
Why? And How have annotations made things better?
Because interfaces should describe functionality - the methods an object will have implemented and how they behave. Additionally, they can be used (abused as well?) for storing constants, like javax.swing.SwingConstants.
Annotations on the other hand give information about a class, method, field, etc (including annotations themselves). Is it deprecated, does the method override another method, etc. Marker interfaces like Serializable and Cloneable do the exact same thing, and could (should) be replaced by annotations like @Serializable and @Cloneable, since they give information about the class. They remain because of backwards compatibility.
Now what Sun maybe should have done is start using annotations, make the marker interfaces deprecated and have the JVM check for presence of either (as to not break old code). Since they haven't, these marker interfaces will not be removed since everybody will continue using them.
Marker interfaces which doesn't have any methods i.e. indicates a rule or protocal.If implements those marker interfaces ,compiler understand and supply by seeing neccessary environment to that classes whichever implements marker interfaces.