Marker Interface in Java

Uğur Taş
Codimis
Published in
5 min readFeb 24, 2024

--

Marker Interface in Java

The marker interface is an interesting concept in Java that can be useful in certain situations. In Java, a Marker Interface is an interface that does not declare any methods. It simply marks (or tags) a class so that we can apply certain behaviors or treatments to instances of that class.

The compiler or runtime environment often uses these interfaces for metadata purposes, indicating something about the class. Since the interface has no methods to implement, its only purpose is to mark a class as having a certain property or characteristic.

If you don’t have a medium membership, you can use this link to reach the article without a paywall.

In this article, we will take a look at what exactly a marker interface is, why you may want to use one, and some common examples of marker interfaces in Java.

What is a Marker Interface?

A marker interface is an interface that does not contain any methods. The JVM or certain classes use it to provide run-time information or to “mark” certain classes. Some key things to understand…

--

--

Uğur Taş
Codimis

A software developer with a high passion for learning, improving skills, and sharing knowledge. My motto is “fail million times if you take lessons every time”