How to override a generic method

后端 未结 3 536
醉梦人生
醉梦人生 2021-01-17 00:05

Generic method :

public  void foo(T t);

Desired overridden method :

public void foo(MyType t);

W

3条回答
  •  礼貌的吻别
    2021-01-17 00:10

    A better design is.

    interface Generic {
        void foo(T t);
    }
    
    class Impl implements Generic {
        @Override
        public void foo(MyType t) { }
    }
    

提交回复
热议问题