You just need to check if the las letter is the same as the first letter and put it inside of a loop. Like
int i = 0;
int j = str.length() -1;
while(i < j)
{
if( str.charAt(i++) != charAt(j--) ) //Checking two letters, the first and the last.
//If the letter were different it would return false
//In any case the variable i will be incremented by 1 and j decreased by 1
return false;
}
return true; //Only if all the letters match.
I think this would work.
Sorry i’m hurry and i can’t check or explain you more. I hope that it works and you understand it.