public void swap(int a, int b) {
int indexA = Arrays.asList(nums).indexOf(a);
int indexB = Arrays.asList(nums).indexOf(b);
nums[indexA] = b;
nums[indexB] = a;
}
public void selectionSort() {
int x = 0;
findIndexOfMinAfter(0);
swap(nums[x], nums[x + 1]);
}
int[] nums is an array I passed in. When I called the swap method, both a and b exist in the array but indexA and indexB return -1. Any idea why it does that?