another null object reference is duplicated

Just declaring your variable cartList, which you did on this line:

     private ArrayList<Inventory> cartList;

is not enough. You also need to initialize this variable with an actual list that you can add items to.

When you declare a variable, you’re telling Java that you plan to use an object of a certain type in your program, and you are telling Java what the name of the variable is along with the type.

But, declaring a variable doesn’t give you an actual list. What you need to do is create a list and store it in your variable. You probably want to do this in the MainViewHolder constructor method. The initialization line might look like this:

 cartList = new ArrayList<Inventory>();

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top