I need a Java code that removes duplicates from an array.
public static java.lang.String[] removeDups(java.lang.String[] arr) {
Returns a new array with duplicate elements removed. The relative ordering of the first occurrence of each element is unchanged. The given array is not modified.
}
Example:
Given the array ["E", "A", "E", "D", "E", "A", "H", "D"], the code should return the array ["E", "A", "D", "H"].
Parameters:
arr - the given array
Returns:
a new array with duplicates removed