+ 2

How are duplicates removed from a given array in Java?

19th Jul 2019, 10:30 AM
Dudley
Dudley - avatar
2 ответов
+ 12
We can remove duplicate element in an arrayby 2 ways: using temporary array or using separate index. To remove the duplicateelement from array, the array must be in sorted order. If array is not sorted, you can sort it by calling Arrays.sort(arr) method. Source: https://www.javatpoint.com/java-program-to-remove-duplicate-element-in-an-array
19th Jul 2019, 10:35 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 1
use hashSet just assign your array to a hashSet.duplicates removed automatically.
19th Jul 2019, 5:01 PM
Sai Ram