title: Not able to add bean to the ArrayList
body: <p>I created a JavaBean class like this.</p>
  
  <pre><code>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;
      }
  
  }
  </code></pre>
  
  <p>Then I created a Servlet, in which got the parameters from HTML file, created a Bean. I am trying to add the bean to the ArrayList.</p>
  
  <pre><code>protected void doPost(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
  
          String companyName = request.getParameter("txtCompany");
          double price = Double.parseDouble(request.getParameter("txtPrice"));
  
          ArrayList&lt;Invoice&gt; list = (ArrayList&lt;Invoice&gt;) new ArrayList();
          Invoice r = new Invoice();
          r.setCompanyName(companyName);
  
          list.add(r.getCompanyName());
          r.setPrice(price);
  
      }
  
  }
  </code></pre>
  
  <p>But I am getting this error on <strong>.add</strong></p>
  
  <pre><code>The method add(Invoice) in the type ArrayList&lt;Invoice&gt; is not applicable for the arguments (String)
  </code></pre>
  
  <p>Where I am might be wrong?</p>