Generic class that extends class and implements interface

前端 未结 4 1219
再見小時候
再見小時候 2021-01-31 06:59

To reduce dependece of class, I want to send parameter (using generic class) to constructor that extends some class and implements interface, for example

public          


        
4条回答
  •  遇见更好的自我
    2021-01-31 07:49

    It's easy if i understand you correct you to have some type T which is extending Fragment and implementing some interface. So you have to write something like that.

    abstract class TemplateFragment extends Fragment implements SomeInterface{}
    

    and then in your classes

    class SomeClass {
    ...
    }
    

    It will do the trick.

提交回复
热议问题