I'm stuck at a task. Maybe someone can help me? I'm given two integer arrays of unknown length like Array 1 = {1, 4, 7, 3} and Array 2 = {1, 7}. I have to return a third Array containing only the integers which are only in one of the arrays. So in this case, Array 3 would be {4, 3}. I've tried something like this:
public static void main(String[] args) {
int [] range = {2, 3, 4, 5, 6, 7};
int [] excludedValues = {1, 4, 6};
int [] exclusionRange = new int [range.length - excludedValues.length + 1];
for (int i = 0; i < range.length ; i++) {
if (range[i] != Arrays.binarySearch(excludedValues, range[i])) {
exclusionRange[i] = range[i];
}
}
System.out.println(Arrays.toString(exclusionRange)); // Should return {2, 3, 5, 7}
}
But it (obviously) doesn't work at all.
Here you can see a detailed description of the content which should be returned:
Thanks for your help in advance :)
