public static boolean isEchoWord(String word) {
for (int i = 0; i < word.length() + 1 / 2; i++) {
if (word.charAt(i) != word.charAt(word.length() - 1 - i)) {
return false;
}
}
return true;
}
public static void main(String args[]) throws IOException {
System.out.println("please input word:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (String input = br.readLine(); !"exit".equals(input); input = br.readLine()) {
System.out.println(isEchoWord(input));
}
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/f636afc379310a559cb25493bb4543a9832610c6?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)