I'm checking if the strings in my array are arranged in alphabetical order. My codechecker is saying that my code fails to account for some cases, but I'm really not sure how to change it.
EDIT: Apparently my code returns "true" when checking the array "cat ape dog zebra", which is clearly false.
public boolean isSorted()
{
boolean sorted = true;
for(int i = 0; i < list.size(); i++)
{
for(int j = i+1; j < list.size(); j++)
{
if (list.get(i).compareTo(list.get(j)) == 1)
{
sorted = false;
}
}
}
return sorted;
}