class product
{
attribute
setter method
getter method
}
public class main...
{
Array List of <Product> products = new ArrayList<Product>();
boolean checkProduct = products.contains(....); // This is the problem how to use contains on this?
}
检查类数组中的值的方法 contains 对此不起作用。
您需要为您的类产品实现 equals 方法。在 Eclipse 中,您可以通过右键单击编辑器,然后选择“源”>“生成 hashCode() 和 equals()”来完成此操作。