Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is the Purpose of Marker Interface in Java?
Posted
Updated 27-Mar-18 23:34pm

In my practice once a marker interface was really very helpful. When I have a project with many independents modules and one core module and need to execute some operations with some of modules in core module. For required classes I implement this marker interface and then in core module only write a check a class
Java
instanceof
interface if yes than execute actions.
 
Share this answer
 
v2
See here[^] for a description of the Marker Interface pattern, and a comment about why it is not a good idea. There is a better alternative (annotations) introduced in Java 5. (Also available in .NET, under a different name.)
 
Share this answer
 
Comments
Dalek Dave 20-May-11 2:55am    
Nice answer.
Marker Interface is an Interface which doesn't have any methods which is used to perform certain functionality Ex: Serializable is a marker interface which is used to perform operations like serialzation and deserization
 
Share this answer
 
v2
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900