hi every body i have a problem whit the condition to check if the element is duplicate element or not
this is the problem
Duplicate Elimination
Use a one-dimensional array to solve the following problem: Write an application that inputs 10 integers. As each number is read, display it only if it is not a duplicate of a number already read. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user inputs all values.
Sample Output:
Enter 10 integers:
12 33 67 9 10 6 6 34 10 19
Unique Values:
12 33 67 9 10 6 34 19
note the question ask to reprint the array but without any repeating number
this is my code
import java.util.Scanner;
public class duplicate
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int[] array = new int[10];
int[] barray = new int[10];
System.out.println(" Enter 10 integers: ");
int i ;
for(i=0;i<array.length;i++)
{
array[i]= input.nextInt();
barray[i] = array[i];
}
for(i=0;i<array.length;i++)
{
System.out.printf("\t %d ",array[i]);
}
System.out.println("\n Unique values are: ");
for ( i = 0; i < array.length; i++ )
{
{
if ( array[ i ] == barray[ i ] )
break;
System.out.printf("\t %d",array[i]);
}
}
}
}