问个菜鸟问题,怎么判断字符串是回文,给程序最好了。谢谢了。
java中判断字符串回文

解决方案 »

  1.   

    package com.bob.abstraction.recursion;/**
     * <p>Title: 回文测试</p>
     *
     * <p>Description: 递归的方法测试一个输入的字符串是否为回文</p>
     *
     * <p>Copyright: Copyright (c) 2005</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    public class isPal {    private String stringItem;    private boolean flag = false;    public isPal() {    }    public boolean execute(String item) {        if (item.length() == 0 || item.length() == 1) {            this.flag = true;        } else
            if (item.substring(0,
                1).equals(item.substring(item.length() - 1, item.length()))) {            execute(item.substring(1, item.length() - 1));        } else {            this.flag = false;        }        return this.flag;
        }    public static void main(String para[]) {        isPal a = new isPal();
            System.out.println(a.execute("1212313"));    }}