Trying to interpret error message...
Can anyone help me make some sence of this message:
StorageBusiness.java:49: cannot find symbol
symbol : method add(java.lang.Object)
location: class java.util.ArrayList<Customer>
return getCustomer().add(inCustomer);
^__
It's obviously expecting something other than what I have.
Thank you
I thought add.() was a defined method already and you don't need it in a particular class. Here's the code it refers to:
// This method adds a customer ...
public boolean addCustomer(Object inCustomer)
{
if (inCustomer instanceof Customer)
return getCustomer().add(inCustomer);
else
return false;
}
So would I have to define add(Object o) in Customer as you suggest.
public boolean addCustomer(Object inCustomer)
{
if (inCustomer instanceof Customer)
return getCustomer().add((Customer)inCustomer);
else
return false;
}
of course ....you need to add . Other thing is from your code , it seems that you have deined an arraylist of customers. if you want to add it ot the arraylist then , you can add it to Arraylist directly because add is pre-defiend method of ArrayList . But in that case you should add object to List not to the customer oject. For example if you ahve
ArrayList<Customer> a1=new ArrayList();
then you can a1.add(Obj); directly if Obj is of type Customer. I hope you need this kind of code