I have instance with getters and setters in my Customer Class
private Collection<CustomersDetails> customerDetails = new ArrayList<CustomersDetails>();
public Collection<CustomersDetails> getCustomerDetails() {
return customerDetails;
}
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
but when i am trying to pass
CustomersDetails customersDetails = new CustomersDetails();
customersDetails.set....
customersDetails.set....
Customer customer = new Customer();
customer.setCustomerDetails(customersDetails);
its giving me error
The method setCustomerDetails(Collection<CustomersDetails>) in the type Customer is not applicable for the arguments (CustomersDetails)
Why its so , when my collection is of CustomersDetails type??
Your Customer
class has a method
public void setCustomerDetails(Collection<CustomersDetails> customerDetails) {
this.customerDetails = customerDetails;
}
You are trying to invoke it with an argument of type CustomersDetails
. A CustomersDetails
is not a Collection<CustomersDetails>
. Wrap the element in a List
or other Collection
.
Something like
customer.setCustomerDetails(Arrays.asList(customersDetails));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.