判断是否是回文

public class huiwen {

    public static void main(String[] args) {
        String str = "abcba";

        String b = new StringBuffer(str).reverse().toString();

        if(str.equals(b)){
            System.out.println("是回文");
        }else{
            System.out.println("不是回文");
        }
    }

}

 

posted @ 2017-05-02 21:02  苏轼的红烧肉  阅读(106)  评论(0编辑  收藏  举报