You can use the modulo operator to determine whether the word has an even or odd number of letters (% in java)
if ( (word.length % 2) == 1 ) {
//odd
}
else {
//even
}
then just split the string in half and compare the reverse of the end with the front
int halfLength = word.length / 2;
String firstHalf = word.substring(0, halfLength);
String secondHalf = word.substring(halfLength, word.length);
if (firstHalf.equals(secondHalf.reverse()) {
//they match
}
something like this should work, I just wrote it up real quick, might need to make a few changes to match java syntax.
2
solved Programming java to determine a symmetrical word [closed]