首页 > 代码库 > 判断是否是回文数

判断是否是回文数

public static void huiwen(){
        System.out.println("请输入一串字符串");
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        StringBuffer sb = new StringBuffer(str);
        if(str.equals(sb.reverse().toString())){
            System.out.println("这串字符串是回文数");
        }else{
            System.out.println("这串字符串不是回文数");
        }
    }

 

判断是否是回文数