Monday, March 26, 2007

Marker Interface

One of the features of the Java programming language is that it mandates a separation between interfaces (pure behavior) and classes (state and behavior). Interfaces are used in Java to specify the behavior of derived classes. Often you will come across interfaces in Java that have no behavior. In other words, they are just empty interface definitions. These are known
as marker interfaces.

Some examples of marker interfaces in the Java API include:
* java,lang.Cloneable
* java,io.Serializable

* java.util.EventListener,etc.

Marker interfaces are also called "tag" interfaces since they tag all the derived classes into a category based on their purpose.

No comments: