A
ajay.kalyan
I am trying to add an object to an arraylist, but first I need to see
if the an object with a specified instance value already exists in the
arraylist. The Contains(obj) function checks the entire object but I
only need to check 1 instance variable in the object and return true or
false based on that.
My java experience tells me that it might have something to do with the
CompareTo() method, but I dont even know if the CompareTo method is
being used in the Contains() method. How would I go about creating a
Contains(string). Can I not override some method to get the desired
result or do I have to manually iterate the arraylist and check each
object?
Any help would be appreciated.
thanks
if the an object with a specified instance value already exists in the
arraylist. The Contains(obj) function checks the entire object but I
only need to check 1 instance variable in the object and return true or
false based on that.
My java experience tells me that it might have something to do with the
CompareTo() method, but I dont even know if the CompareTo method is
being used in the Contains() method. How would I go about creating a
Contains(string). Can I not override some method to get the desired
result or do I have to manually iterate the arraylist and check each
object?
Any help would be appreciated.
thanks