I have the following code which iterates on an Integer[] and makes sure that the the values in the array are in ascending order and that there are no neighbouring duplicates:Integer previous = null;for (Integer tb : trancheBoundaries) {    if (previous == tb) {        throw new IllegalThresholdConfigurationException(Two boundaries are the same);    } else if (previous != null && previous > tb) {        throw new IllegalThresholdConfigurationException(Previous is larger than current - tranche boundaries must be in ascending order);    } else {        previous = tb;    }}I am getting a warning from Sonar warning of suspicious comparison of integer references on the first if clause.I know why I am getting this, but in a situation like this, is it bad practice? I think it's ok because I know that I will always be comparing the same instances.
Suspicious comparison of integer references while checking for a monotonically increasing sequence
java;validation;null;reference
Integer[] vs int[]This may be down to a 'personal preference' thing, but using primitive wrappers in an array instead of a Collection seems a little odd. This is because it lets null values sneak into the array compared to a 'plain' int[], and speaking of which...Boundary casesWhen this loop encounters a null (previous == null), is it really because two boundaries are the same?When equal numbers are encountered consecutively (previous == tb), is this really a case of valid ascending order?MiscellaneousYou can opt to remove the final else clause as previous = tb is the final 'step' in your comparison. Again, I think this is a personal preferences thing, as some may prefer to see the 'boundaries' of the if-blocks.