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
Marker interfaces can be replaced with annotations in many places, however a marker interfaces can still be used for
The compile time checks. You can have a method which must take an object of a class with a given marker interface(s) e.g.
public void myMethod(MyMarkerInterface MMI);
You cannot have this compile time check using an annotation alone.
BTW: You can have two interfaces using generics, but good examples are rare.
EDIT: I use this for a Listener marker interface. A listener has methods methods marked with annotations but the methods can have any name or type. It adds a compiler time check to what would otherwise be a purely runtime linking.
public Component implements Listener {
@ListenerCallback
public void onEventOne(EventOne... eventOneBatch) { }
@ListenerCallback
public void onEventTwo(EventTwo eventTwo) { }
}