Not sure where I am going wrong with this, the false statement seems to work fine but I am getting and out of range error whenever i try to obtain true. clarifying, what i want this to do is make sure the ASCII code is increasing with every follows letter, if not return false, is so return true
public static String isOrdered(String a) {
int i = 0;
while (i < a.length())// Here we have a loop to compare the whole
// string, to make sure all the values are
// increasing.
{
char x = a.charAt(i);// Grabbing the part of the string we need to
// start comparing
char y = a.charAt(i + 1);
{
if (x > y)// here we are comparing the value of i, to the value
// next in the string to make sure that the values
// are increasing
{
String answer = "false";
return answer;
} else if (i >= a.length()) {
String answer = "true";
return answer;
}
}
i++;
}
String answer = "true";
return answer;
}