List is a raw type. References to generic type List should be parameterized

编译环境:Eclipse

问题:编译集合类型List、Set、Map代码时,编译器出现下面的警告:

List is a raw type. References to generic type List should be parameterized
Set is a raw type. References to generic type Set should be parameterized
Map is a raw type. References to generic type Map should be parameterized

具体的问题代码:

List addressList;

public void setAddressList(List addressList) {
    this.addressList=addressList;
}
public List getAddressList() {
    System.out.println("List Elements :" + addressList);
    return addressList;
}

  List is a raw type. References to generic type List should be parameterized_第1张图片

警告的内容是,需要我们给出数据的原始类型,具体的修改方法如下:

List addressList;

public void setAddressList(List addressList) {
    this.addressList=addressList;
}
public List getAddressList() {
    System.out.println("List Elements :" + addressList);
    return addressList;
}

问题下成功解决。

Set集合类型跟List集合类型一样,具体说一下Map集合类型。

Map、HashMap集合类型问题总结:(因为这两种集合类型都需要指出具体的key值和value值)

问题:
Map.Entry is a raw type. References to generic type Map.Entry should be parameterized
解决方法:
HashMap addressHash;
HashMap addressHash;
Map addressMap;

 

你可能感兴趣的:(Spring)