Java- Getting unexpected type error when declaring new generic set

前端 未结 2 1872
天命终不由人
天命终不由人 2021-01-02 07:29

I thought I knew what I was doing with generics, but apparently not.

ArraySetList setA = new ArraySetList();

When c

2条回答
  •  清歌不尽
    2021-01-02 08:02

    Generic type arguments require reference types (or wilcards).

    You can't use primitive types (for more see restrictions);

    ArraySetList setA = new ArraySetList();
    

    Read JLS 4.5.1 Type Arguments and Wildcards for usable types

提交回复
热议问题