I having a problem with coding this:
Write a static method named removeDuplicates that takes as input an array of integers and returns as a result a new
removeDuplicates
Try this
public static int[] removeDuplicates(int[] s) { Integer[] array = new HashSet(Arrays.asList(ArrayUtils.toObject(s))).toArray(new Integer[0]); return ArrayUtils.toPrimitive(array); }
Edit: Updated with Apache Lang to convert to primitives.