public class RemDupFromList {
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("one");
list.add("one");
//We have facility to pass List into Set constructor and vice versa to cast
//List<String> list1 = new ArrayList<String>(new HashSet<>(list));
//If you need to preserve the order use 'LinkedHashSet'
List<String> list1 = new ArrayList<String>(new LinkedHashSet<>(list));
Iterator<String> it = list1.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}