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)
yes it is correct. it is called Marker Interface.
http://en.wikipedia.org/wiki/Marker_interface_pattern
Yes it's OK to do that.
When an interface has no methods, it's generally called a marker interface; Serializable is one of many examples of such an interface from the JDK.
Also, you probably don't want "class" in your interface name. Just Event is a better choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With