Filter for duplicate elements I wrote code to filter for duplicate elements in an array. I'd like to know your opinion, whether it's efficient at all, or if there's too many objects created, use of both array and list. That's in preparation for an interview. I'm not interested in lambdas (distinct) or helper methods, I'd like to see where I can improve and understand what's efficient or not in what I wrote, also without using Set, HashSet.
public class Duplicate {
    public static void main (String [] args){
        // filter duplicate elements
        int [] arr = {5,4,3,5,4,6,7,8,6};
        Arrays.sort(arr);
        int length = arr.length;
        List&lt;Integer&gt; list = new ArrayList&lt;&gt;();
        list.add(arr[0]);
        for(int i =0; i &lt;length-1;i++){
            if(arr[i] != arr[i+1]){
                list.add(arr[i+1]);
            }
        }
        System.out.println(Arrays.toString(list.toArray()));
    }
}
You can add the items to a Set instead of a List to avoid duplicates. That way you delegate to Set for uniqueness:
int [] arr = {5, 4, 3, 5, 4, 6, 7, 8, 6};

Set&lt;Integer&gt; set = new HashSet&lt;&gt;();

int length = arr.length;

for(int i = 0; i &lt; length; i++){
    set.add(arr[i]);
}

System.out.println(Arrays.toString(set.toArray()));