I have to make an array of 10 numbers then copy that array into a new array without the duplicates. I got it to the point where it will weed out dups but for some reason after I determine that a number is not already in the new array it wont let me put it in there. This is what I have so far.Thanks.
import java.util.*; import java.io.*; public class PrintingDistinctNumbers { public static void main(String[] args) { int[] array=new int[10]; int[] array2=new int[10]; int num1; int count = 0; boolean results; //let the user input 10 numbers for(int i=0;i<array.length;i++) { Scanner input=new Scanner(System.in); System.out.println("please enter 10 numbers"); num1=input.nextInt(); array[i]=num1; } for (int j=0;j<array.length;j++) { results=search(array2 ,array[j],count); if(results=false); { array[j]=array2[count]; count++; break; } } // just a test to make sure the numbers copied over to the new array System.out.println(array2[0]); } //search the second array to see if the int is allready in it public static boolean search(int[] array2,int value,int count2) { //create variables boolean found; //set the variables found= false; //search the array for(int index=0;index<count2;index++) { if(array2[index]==value) { found=true; break; } } return found; } }