So basically, I have one array, with ten values...
int[] input = new int[10];
The user controls the input to each value.
What would be a good technique to check to see if any of the values inside of the array are equal to any of the other values?
Edit:
public static void main(String[] args) {
P2 numbers = new P2();
for (int i = 0; i < numbers.input.length; i++) {
numbers.input[i] = numbers.scan.nextInt();
}
numbers.Check();
if (numbers.Check()) { System.out.println("Duplicate"); }
if (numbers.Check() == false) { System.out.println("NOT Duplicate"); }
}
public boolean Check() {
int length = input.length;
for(int i : input) {
for(int j = i + 1; j < length; j++) {
if(input[i] == input[j]) return true;
}
}
return false;
}
The codes works ask long as duplicate numbers are index-neighbors.