/** * @author lautturi.com * Java example: remove duplicate elements of list in java */ import java.util.*; public class Lautturi { public static void main(String[] args) { List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 3, 4, 5, 2, 7); System.out.println(numbers); Set<Integer> hashSet = new LinkedHashSet(numbers); List<Integer> newList = new ArrayList(hashSet); System.out.println(newList); } }Source:www.lautturi.com
output:
[1, 2, 3, 4, 3, 4, 5, 2, 7] [1, 2, 3, 4, 5, 7]