java - For loop not running in method -
for reason loop not running , can't seem figure out why. keeps skipping straight return statement. thanks.
public char[] palindromecheck(char[] original) { char[] reversed = new char[original.length]; (int = original.length; <0; i--) { switch (original[i]){ case 'a': original[i] = character.tolowercase(original[i]); break; case 'e': original[i] = character.tolowercase(original[i]); break; case 'i': original[i] = character.tolowercase(original[i]); break; case 'o': original[i] = character.tolowercase(original[i]); break; case 'u': original[i] = character.tolowercase(original[i]); break; default: original[i] = character.touppercase(original[i]); break; } reversed[i] = original[i]; } return reversed; }
for (int = original.length; <0; i--)
the condition false since length >= 0. since you're indexing array, want loop length-1 0 like
for (int = original.length - 1; >= 0; i--)
Comments
Post a Comment