Java Generics Puzzler, extending a class and using wildcards

前端 未结 6 1797
不知归路
不知归路 2021-01-31 02:02

I\'ve been beating my head against this one for awhile and thought that maybe some fresh eyes will see the issue; thanks for your time.

import java.util.*;

clas         


        
6条回答
  •  执笔经年
    2021-01-31 02:27

    You can define the generic types as follows:

    class Tbin extends ArrayList {}
    class TbinList> extends ArrayList {}
    

    Then you would create instance like:

    TbinList> test2 = new TbinList<>();
    test2.add(new Tbin());
    

提交回复
热议问题