Java Remove Duplicates from an Array?

The Simple solution is that use Set of java,

so set remove duplicate value automatically

and in your code you have array than convert array to set directly using code

Set<T> mySet = new HashSet<T>(Arrays.asList(someArray));

Leave a Comment