Putting your arraylist inside a method means it can only be accessed by the method it is in and is lost when the method is finished running. You have two options.
-
Change the return type of your method as an
arraylistand return and manipulate yourarraylist -
Create the
arraylistoutside of a method global to the whole class.
This code block should help:
public class mVentoryHome extends javax.swing.JFrame {
private static ArrayList <ProductInfo> Inventory = new ArrayList<ProductInfo>();
}
3
solved Trouble Adding to an Object in an ArrayList