hi forum. I have a code to return an arrayList with the duplicates of an ArrayList that has the methods get1(), get2(), get3(), get4(),
which are the criteria to see if the object is duplicated, but seems it´s not working, I am comparing all items in the array...
I have:
public ArrayList<ObjectList> duplicates(ArrayList<ObjectList> someObjectsList) {
ArrayList<ObjectList> ret = new ArrayList<ObjectList>();
for ( ObjectList aSomeObjectsList: someObjectsList) {
String field1 = aSomeObjectsList.get1();
String field2 = aSomeObjectsList.get2();
String field3 = aSomeObjectsList.get3();
String field4 = aSomeObjectsList.get4();
if (
field1.trim().equals(someObject.get1())&&
field2.trim().equals(someObject.get2())&&
field3.trim().equals(someObject.get3())&&
field4.trim().equals(someObject.get4())
){
//What else do I have to do
// ret.add(aSomeObjectsList);
}
}
return ret;
}