Examveda

How to remove duplicates from List?

A. HashSet<String> listToSet = new HashSet<String>(duplicateList);

B. HashSet<String> listToSet = duplicateList.toSet();

C. HashSet<String> listToSet = Collections.convertToSet(duplicateList);

D. HashSet<String> listToSet = duplicateList.getSet();

Answer: Option A


This Question Belongs to Java Program >> Collections Framework In Java

Join The Discussion

Related Questions on Collections Framework in java