I'm new to Java. I'm getting the following error from my code:
(Palindrome.jav a:30: error: missing return statement
} // close method)
My code is:
[public class Palindrome { // define class palindrome
public static boolean isPalindrome(St ring inputWord) { //define method
int rightSide = inputWord.lengt h() -1; // right side
while (leftSide < rightSide) { //loops until middle is found.
if ((inputWord.cha rAt(leftSide))! = (inputWord.char At(rightSide))) {
return false; // when letters on each side are not equal
// a false value is returned.
} else {
return true; } // if finished, all chars were same
} // close while stmt
} // close method
} // close class ]
(Palindrome.jav a:30: error: missing return statement
} // close method)
My code is:
[public class Palindrome { // define class palindrome
public static boolean isPalindrome(St ring inputWord) { //define method
int rightSide = inputWord.lengt h() -1; // right side
while (leftSide < rightSide) { //loops until middle is found.
if ((inputWord.cha rAt(leftSide))! = (inputWord.char At(rightSide))) {
return false; // when letters on each side are not equal
// a false value is returned.
} else {
return true; } // if finished, all chars were same
} // close while stmt
} // close method
} // close class ]
Comment