Saturday, 5 March 2016

marker interfaces

                                                            Marker Interfaces in Java


"An interface is called a marker interface when it is provided as a handle by Java interpreter to mark a class so that it can provide special behaviour to it at 
runtime and they do not have any method declarations". 

In the above definition "and they do not have any method declarations" is added because, till now all the marker interfaces provided by Java do not have method 
declarations. 

We cannot create marker interfaces, as you cannot instruct JVM to add special behaviour to all classes implementing (directly) that special interface. 



We don't need to create your own marker interface since it is not recommended by java. For your knowledge I want to make you clear that their 
is no any definition for marker interface in Java specification/api. Whatever we study on web/books is cooked by web developers. 

Now since jdk 1.5 we dont need to use marker interface, in place of this we can use annotations which have their own many advantages.

No comments:

Post a Comment