What is Marker Interface

What is Marker Interface

Answer: A marker interface is an interface with no method declarations. They just tell the compiler that the objects of the classes implementing the interfaces with no defined methods need to be treated differently. These Marker interfaces are used by other code to test for permission to do something.

Java Marker Interface:

  • Serializable
  • Clonable
  • RandomAccess

From java 1.5, Introduction of java annotation feature can be use to define Marker Interface as example shows below:

Marker Interface:

package com.javahonk.markerinterface;

interface MarketInterfaceExample {

}

 

Using Annotation Marker Interface:

@interface
AnnotationUserMarkerInterface{

}

 

Leave a Reply

Your email address will not be published. Required fields are marked *