title: How do I link arraylist values to class objects? (Android)
body: <p>I have a class Sale.java created in Android studio:</p>
  
  <pre><code> public class Sale {
  
  private String Name;
  private double Price;
  private int quantity;
  
   public Sale(String Name, double Price, int quantity) {
      this.Name = Name;
      this.Price = Price;
      this.quantity = quantity;
  
  }
   public String getName() {
       return Name;
  }
  
  public void setName(String Name) {
      this.Name = Name;
  }
  
  public double getPrice() {
      return Price;
  }
  
  public void setPrice(double Price) {
      this.Price = Price;
  }
  
  public int getQuantity() {
      return quantity;
  }
  
  public void setQuantity(int quantity) {
      this.quantity = quantity;
  }
  
   } 
  </code></pre>
  
  <p>In my mainactivity.java, I want to create an Arraylist to store each Sale object dynamically and also keep track of which Sale object belongs to which "index" from the Arraylist by using for loop in the future.</p>
  
  <pre><code>//Arraylist for storing information about items
  ArrayList&lt;Sale&gt; iteminfo = new ArrayList&lt;&gt;();
  Sale scheck;
  
   EditText ItemName;
  EditText ItemPrice;
  EditText Itemqty;
  
   protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_sales);
  
      ItemName = (EditText) findViewById(R.id.addName);
      ItemCostPrice = (EditText) findViewById(R.id.addprice);
      ItemQty = (EditText) findViewById(R.id.addqty);
  
  
   btnSaveinfo.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
      double Price = Double.parseDouble(ItemPrice.getText().toString());
                  double Qty = 
   Double.parseDouble((ItemQty.getText().toString()));
              string Name = ItemName.getText().toString();
  
     scheck = new Sale(Name, Price, Qty);
  
  
   } }
  </code></pre>
  
  <p>How do I code such that every time the button is clicked, an object of Sale is created which links it to ArrayList ? Have I done it right by declaring Arraylist as object type? Please help.</p>