Markers - Interfaces with no Methods defined

You might have come across many interfaces ,which doesn't have any methods defined. most common example is java.io.Serializable Class
The interface with no defined methods act like "Markers". They just tell the compiler that the object of classes implementing the interface with no defined methods need to be treated differently.

For example 
java.io.Serializable
java.lang.Clonable
java.util.EventListener

Markers are also known as "Tag" interface since they tag all the derived classes into  a category based on their purpose.


Comments

Popular posts from this blog

Composite Design Pattern by example

State Design Pattern by Example

Eclipse command framework core expression: Property tester