Getting error for generic interface: The interface Observer cannot be implemented more than once with different arguments:

后端 未结 3 817
走了就别回头了
走了就别回头了 2020-12-07 01:46

I am getting this error in Eclipse while writing a GWT app

The interface Observer cannot be implemented more than once with different arguments:

3条回答
  •  暖寄归人
    2020-12-07 01:59

    Not sure this can help, but I came across the same Java compile error today.

    I partially solved my case by extracting all the shared implementation I could get to a parametrized abstract class:

    public enum Example {
        ;
        static interface Observer { public void update (T o); }
        static abstract AbstractObserver implements Observer {
            public void update (T o) { /* shared stuff I can put here */ }
        }
        static Composite extends AbstractObserver {
            public void update (T o) {
                super(o);
                /* type-specific code here */
            }
        }
        static CompositeWordLists extends AbstractObserver {
            public void update (T o) {
                super(o);
                /* type-specific code here */
            }
        }
    }
    

提交回复
热议问题