I've a Class called Products. This class has a name and a price.
I can create a product the following way:
Product book = new Product();
book.setName("book");
book.setPrice(3);
After that I'm supposed check if this product already exists in the ArrayList I'm supposed to save it to and if it doesn't, then I just put it there. I'm supposed to do this using the following:
public boolean equals(Object obj){
}
The problem is, how am I supposed to do it, if the ArrayList I'm supposed to save the product in, is created and initialised in the public static void main while this boolean is created before the ArrayList even exists?
Should I just make the Class itself an ArrayList, like so?
public class ArrayList<Product>{
}