Vector: indexOf(Object elem)
Searches for the first occurrence of the given argument, testing for equality using the equals method.
Your Vector is filled with Customer objects, yet you are trying to look up these objects with Strings, you cannot compare a Customer object with a String object, they are not the same thing.
You could use a Map<String, Customer> to do this. Or you can turn that String value parameter to a Customer object that you can compare with value objects in the Vector.
Joined: Sep 30, 2010
Hi there Thank you for the quick reply
I am very new at java, i understood the comparison problem.( String vs Object).
how can i convert the String value parameter to a Customer object and then compare it with value objects in the Vector ??
i have never used Map<String, Customer> before.
Thank you for time and interest.
Joined: Sep 15, 2010
What I mean by create a Customer from the String is, there is a constructor that accepts parameters, you use this here.
This creates a Customer object that holds that customers information.
The point of this exercise appears to be that you are to get a customer based on their name. Now the question becomes, have you learned the equals method?
If you have you would override this method to compare Customer objects.
However, you may not have learned this yet, in which case you can identify each customer by name. So you would loop through all of the Customers in the Vector list and get their name. Once you have their name you can compare it with the String name you have passed in to the method.
This is assuming that the text typed in is the name of the Customer you are looking for, I have also assumed you know how to get object properties.
for more help I recommend Googling 'java constructors'; 'java String comparison' ; 'java equals method'