package book.chapter6.demo2; import java.util.Scanner; //回文串 public class Text8 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String s=scanner.nextLine(); boolean a=isHuiString(s); if(a==true){ System.out.println(s +"is palindrome"); }else{ System.out.println(s +" is not palindrome"); } } public static boolean isHuiString(String s){ int l=0; int r=s.length()-1; while(l<r){ if(s.charAt(r) != s.charAt(l)){ return false; } l++; r--; } return true; } }
标签:scanner,System,Scanner,回文,public,String From: https://www.cnblogs.com/wyw161454-0007/p/16715849.html