Create Add to cart option using ArrayList

0
 Create Add to cart option using ArrayList

We can create UserDefine Class type ArrayList to create cart.



step1st:-

Create Cart Class

class Cart
{
     public int cartid;
     public String cartitem;

    Cart(int cartid,String cartname)
   {
      this.cartid=cartid;
      this.cartname=cartname;

   }
 }



step2nd:-

Create Cart Type ArrayList

ArrayList<Cart> obj = new ArrayList<Cart>();


Step3rd:-

Add item into the arraylist

obj.add(new Cart(item1,item2));




Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)