Filter for duplicate elements
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()));