Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is marker interface in java?

Tags:

java

Marker interface is an interface without any members. And serializable is one example for that .

Can we define our own marker interface. If yes how can we define functionality for it.?

like image 950
Chetan Joshi Avatar asked Jan 28 '26 16:01

Chetan Joshi


1 Answers

Marker interface is used as a tag to inform a message to the java compiler so that it can add special behaviour to the class implementing it.

Java marker interface has no members in it.

Ex. 1. java.io.Serializable is Marker interface.

  1. java.lang.Cloneable
like image 162
Prashant Kadam Avatar answered Jan 31 '26 06:01

Prashant Kadam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!