If a Marker Interface does not have any methods, how does it work?

后端 未结 5 1939
长情又很酷
长情又很酷 2020-11-27 21:08

I am aware of what marker interface is and when we need to use it. One question is still not clear to me. If a marker interface does not have any method or body, how does

5条回答
  •  半阙折子戏
    2020-11-27 21:26

    Marker interface in Java is interfaces with no field or methods or in simple word empty interface in java is called marker interface. e.g. serializable, Clonnable and Remote Interface. They are used to indicate signal or command to the compiler Or JVM. It can also be used to classify code. You can also write your own marker interface and use them to logically divide your code. Also, you can write any pre-processing operation on those class.

提交回复
热议问题