Possible Duplicate:
Prevent duplicate entries in arraylist
I have an arraylist of a particular class C.
List<C> myList = new ArrayList<C>();
Class C has two attributes viz.
String str1;
String str2;
Now as and when I am adding objects of type C to the ArrayList myList, I want to check if there already exists an object in the list with the values of str1 and str2 matching the values of the parameters (str1 and str2) of the object I am about to add.
Is there any efficient way to do this without having to iterate everytime through the complete list and checking for matching between the parameters?