You code will work only if the string lenght is odd. Wont work if it is even
boolean isPalindrome(String s) {
int i=0, j = s.length( ) -1;
while ( i !=j && s.charAt(i)==s.charAt(j)) {
i++;
j--;
}
return (i==j);
}
try these changes it will work
boolean isPalindrome(String s) {
int i=0, j = s.length( ) -1;
while ( i !=j && s.charAt(i)==s.charAt(j)) {
// change the condition here from i!=j to i<=j
i++;
j--;
}
return (i==j);
//Change the condition here from i==j to i>j
}
good luck