In my android development I am getting particular data from api. And using that data I iterate to create HashSet. The purpose of this implementation is to remove the duplicates. But still duplicate is presenting.
for(int i=0;i<array.length();i++) {
HashSet<String> hashSetObject = new HashSet<String>();
hashSetObject.add(leagueName);
Log.d("HASHSET","values in HashSet object " + hashSetObject.toString());
}
In the above coding leagueName
is a string from api. and the output of this code is as below...
D/HASHSET: values in HashSet object [League One]
D/HASHSET: values in HashSet object [Championship]
D/HASHSET: values in HashSet object [Premiership]
D/HASHSET: values in HashSet object [Championship]
D/HASHSET: values in HashSet object [League One]
D/HASHSET: values in HashSet object [Premiership]
.....
I need a HashSet without duplicates. Please help me.