标签:text bool can java system.in string toc out ++
package com.lkr.dataStructure;
import java.util.Scanner;
public class HuiwenString {
public static void main(String[] args){
System.out.println("请输入字符串");
Scanner input = new Scanner(System.in);
String s = input.next();
boolean isHuiWen = isHuiwen(s);
if(isHuiWen){
System.out.println(s + "是回文串");
}
else System.out.println(s + "不是回文串");
}
public static boolean isHuiwen(String text){
int length = text.length();
for(int i=0;i<length/2;i++){
if(text.toCharArray()[i] != text.toCharArray()[length-i-1]){
return false;
}
}
return true;
}
}
标签:text bool can java system.in string toc out ++
原文地址:https://www.cnblogs.com/turningli/p/10404395.html