1.

How to remove duplicates from List?(a) HashSet listToSet = new HashSet(duplicateList);(b) HashSet listToSet = duplicateList.toSet();(c) HashSet listToSet = Collections.convertToSet(duplicateList);(d) HashSet listToSet = duplicateList.getSet();

Answer» Correct option is (a) HashSet listToSet = new HashSet(duplicateList);

Explanation: Duplicate elements are allowed in List. Set contains unique objects.


Discussion

No Comment Found

Related InterviewSolutions