Ad Code

✨🎆 Diwali Dhamaka Offer! 🎆✨

Get 20% OFF on All Courses at Shiva Concept Solution click

Create Add to cart option using ArrayList

 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

0 Comments