Java 具有泛型类型参数的方法可以传递泛型类型参数
在我的客户类中有getter和setter实例Java 具有泛型类型参数的方法可以传递泛型类型参数,java,Java,在我的客户类中有getter和setter实例 private Collection<CustomersDetails> customerDetails = new ArrayList<CustomersDetails>(); public Collection<CustomersDetails> getCustomerDetails() { return customerDetails; } public void
private Collection<CustomersDetails> customerDetails = new ArrayList<CustomersDetails>();
public Collection<CustomersDetails> getCustomerDetails() {
return customerDetails;
}
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
这给了我错误
The method setCustomerDetails(Collection<CustomersDetails>) in the type Customer is not applicable for the arguments (CustomersDetails)
类型Customer中的方法setCustomerDetails(Collection)不适用于参数(CustomerDetails)
为什么会这样,当我的收藏是CustomerDetails类型时???您的
Customer
类有一个方法
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
您的
Customer
类有一个方法
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
您的
Customer
类有一个方法
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
您的
Customer
类有一个方法
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
我在这里没有看到任何原始类型。这只是一个常规类型不匹配。@Radiodef你说得对。我在这里没有看到任何原始类型。这只是一个常规类型不匹配。@Radiodef你说得对。我在这里没有看到任何原始类型。这只是一个常规类型不匹配。@Radiodef你说得对。我在这里没有看到任何原始类型。这只是一个常规的类型不匹配。@Radiodef你说得对。