I am having troubles combing both arrays to execute within the loop. I have confused myself way to long with this simple program. I am supposed to write a program that reads 10 numbers and displays the distinct numbers. Example layout of the output is:
Enter an integer: 1
Enter an integer: 3
Enter an integer: 2
Enter an integer: 1
Enter an integer: 5
Enter an integer: 4
Enter an integer: 5
Enter an integer: 2
Enter an integer: 4
Enter an integer: 5
The number of distinct values is 5
1 3 2 5 4
My code is:
Ireneusz Kordal
Ranch Hand
Joined: Jun 21, 2008
Posts: 423
posted
0
Hi,
use Set to display distinct values. I guess you want to display them in the order they were entered - LinkedHashSet is ideal to do this.
Look at this example: