I have an object of type
Couple(String person1, String person2)
,
and an ArrayList<Couple> relationshipList = new ArrayList<Couple>();
that has various items of Couple type, where all Couple objects are duplicated once in the list.
For example, this is my sample arrayList:
relationshipList.add(new Couple("John", "Amy"));
relationshipList.add(new Couple("Eliot", "Megan"));
relationshipList.add(new Couple("Billy", "Rachel"));
relationshipList.add(new Couple("Amy", "John"));
relationshipList.add(new Couple("Jim", "Kate"));
relationshipList.add(new Couple("Kate", "Jim"));
relationshipList.add(new Couple("Megan", "Eliot"));
relationshipList.add(new Couple("Rachel", "Billy"));
I'm trying to find a way to remove the duplicate couples, because as in this example, John and Amy are the same couple added twice in the list, with just their names swapped in the column.(assuming two people with the same names doesn't exist in this scenario and John refers to only the "John and Amy" couple) Can anyone help me on this?