Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

array remove duplicate in java

List<Integer>numbers = Arrays.asList(1,2,2,2,3,5); // [1, 2, 3, 5]
System.out.println(numbers);

Set<Integer> hashSet = new LinkedHashSet(numbers);
ArrayList<Integer> removedDuplicates = new ArrayList(hashSet);
System.out.println(removedDuplicates); // [1, 2, 3, 5]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #remove #duplicate #java
ADD COMMENT
Topic
Name
5+2 =