이렇게 JavaBean 클래스를 생성했습니다.빈을 ArrayList에 추가 할 수 없습니다.
package beans;
public class Invoice {
private String companyName;
private double price;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
그런 다음 HTML 파일의 매개 변수를 가져 와서 빈을 작성한 서블릿을 만들었습니다. 빈을 ArrayList에 추가하려고합니다.
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String companyName = request.getParameter("txtCompany");
double price = Double.parseDouble(request.getParameter("txtPrice"));
ArrayList<Invoice> list = (ArrayList<Invoice>) new ArrayList();
Invoice r = new Invoice();
r.setCompanyName(companyName);
list.add(r.getCompanyName());
r.setPrice(price);
}
}
하지만 에이 오류가 내가 잘못 될 수도입니다
The method add(Invoice) in the type ArrayList<Invoice> is not applicable for the arguments (String)
을 .add는 무엇입니까?