if (value.compareTo(elementData[size]) >= 0) {
elementData[size + 1] = value;
size++;
} else if (value.compareTo(elementData[0]) <= 0) {
for (int i = size; i >= 0; i--) {
elementData[i + 1]= elementData[i];
}
elementData[0] = value;
size++;
}
The very first if statement should return a positive number from the compareTo. I've debugged and confirmed that it does return a positive number however it doesn't enter the block.
I'm comparing strings that like these "str1" "str2"... etc. It works fine until I get to "str10" and have to compare it to "str9". It's saying that "str10" is less than "str9" does that make any sense?
It happens every 10 iterations. So my array looks like [str0, str1, str10...str19,str2, str20, str21, ... str29..etc]