If you want to remove duplicate entries from your array list you can use hash set to make all items unique rather than use of algorithms.
Set is a ordered collection of items and contains only unique items. And Hashset creates a collection that uses a hash table for storage. It stores items by using Hashing maintain key for each items and remove duplication.
Set<String> hsName = new HashSet<>();
Set<String> hsId = new HashSet<>();
ArrayList<String> alName = new ArrayList<>();
ArrayList<String> alId = new ArrayList<>();
for (int i = 0 ; i< yourList.size();i++){
alName.add(yourList.get(i).getSkillName());
alId.add(yourList.get(i).getSkillId());
}
hsName.addAll(alName);
alName.clear();
alName.addAll(hsName);
hsId.addAll(alId);
alId.clear();
alId.addAll(hsId);
0 Comment(s)