During writing a code I had an one bug. It was in this block of code:
if (isNewMinFound) {
swap(inputArray, currentIndex, minIndex);
isNewMinFound = false;
}
I've forgoten to return the value of isNewMinFound to false in case if new minimal value is found. :scream_cat:
I had an example of Cut-and-Paste Programming antipattern example also. I tried to find an existing solution to swap elements in an array, and I have found it in Internet, so I have copied and pasted it to my code without any changes. I have declared swap() method as public static final, but it was not necessary.
I've forgoten to return the value of
isNewMinFound
tofalse
in case if new minimal value is found. :scream_cat:swap()
method aspublic static final
, but it was not necessary.