I'm trying to crate my own thread safe event handling but I get E cannot be resolved to a type error on class decleration line below. How can I fix this?
Observers.java
public final class Observers> {
private CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList();
public interface EventHandler {
public void HandleEvent(Object sender, E e);
}
/*...*/
public void dispatchEvent(Object sender, E args) {
/*...*/
}
}
EventHandler.java
public interface EventHandler {
/* ... */
}
解决方案
You've only actually declared a single type parameter in Observers. Try this:
public final class Observers> {
Note that it looks highly odd for your Observers class to declare its own nested EventHandler interface while implementing the outer one - if you really need both of those, I would suggest you rename one of them.