Topic
is an object made up of:
String Name
Int Id
e.g.
topic1:
Name: Topic1
Id: 1
topic2:
Name: Topic1
Id: 2
I have a list of {topic1, topic2}
I want a list of topics with unique names. So my ideal output would be a list containing just {topic1}
.
.distinct()
doesn't work because the Ids are different, so the objects are different.
How do I get this in Java?