Answer:
import java.util.Scanner;
public class num8 {
public static boolean isPali(String word)
{
int i = 0, j = word.length() - 1;
// compare characters
while (i < j) {
// check for match
if (word.charAt(i) != word.charAt(j))
return false;
i++;
j--;
}
return true;
}
// Main Method
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word to test for palidrone");
String str = in.nextLine();
if (isPali(str))
System.out.print(str+" is Palidrone");
else
System.out.print(str+ "is not palidrone");
}
}
Explanation: