Search code examples
javainterfaceextend

Java - extend an interface


Is it correct to extend an empty interface? I just need to have a method (EventPlayer) with a parameter (EventCLass myEvent) that could be one time a class and the next time another class.

public interface EventClass {
  // ... empty ...
}

public interface EventClassExt1 extends EventClass {

    public void firstEvent();

    public void secondEvent();
}


public interface EventClassExt2 extends EventClass {

    public void thirdEvent(String text);
}

public EventPlayer(final EventCLass myEvent) 

Solution

  • yes it is correct. it is called Marker Interface.

    http://en.wikipedia.org/wiki/Marker_interface_pattern