public class EliminateDuplicates{ public static int[] eliminateDuplicates(int[] numbers) { int[] temp = new int[numbers.length]; int size = 0; for (int i = 0; i < numbers.length; i++) { if (linearSearch(temp, numbers[i]) == -1) { } } int[] result = new int[size]; for (int i = 0; i < size; i++) result[i] = temp[i]; return result; } public static int linearSearch(int[] list, int key){ for(int i=0;i<list.length;i++){ if(key==list[i]) return i; } return -1; } public static void main(String[] args){ int[] numbers=new int[10]; java.util.Scanner input=new java.util.Scanner(System.in); System.out.print("Enter ten integers: "); for(int i=0;i<numbers.length;i++){ numbers[i]=input.nextInt(); } int[] result=eliminateDuplicates(numbers); System.out.println("The number of distinct integers is "+result.length); System.out.print("The distinct integers are "); for(int e:result) System.out.print(e+" "); } }

I'm trying to write code that the user puts in 10 integers and gives how many distinct numbers and what those numbers are. I having trouble figuring out how to remove the duplicate numbers. I think it has to do with lines 6 to 8 unless it has to do something with linearSearch(lines 15-21). Can somebody help me what I'm doing wrong?