android - Last variable in arraylist is overriding all variables -
this productcatalogclass :
public class productcatalogclass { private arraylist<productclass> productlist; public arraylist addproduct() { // ... return productlist; } } this productclass :
public class productclass { private string productname; private string availability; private int price; // getters , setters } ... how should resolve this? i know of methods not completed can't finish until figure out how fix arraylist issue
when add product productlist, reference object added (something pointers in c). if add same object list ten times, have list of ten references 1 object.
you should create new product every time want add list.
Comments
Post a Comment