Java判断字符串是否是回文

public class IfHuiWen2 {

	public IfHuiWen2() {
		// TODO Auto-generated constructor stub
		String value = "12321";
		boolean yesorno = PanDuanHuiWen(value);
		System.out.println(yesorno);
	}

	private boolean PanDuanHuiWen(String value) {
		// TODO Auto-generated method stub
		boolean flag = false;
		byte[] byteval = value.getBytes();

		for (int k = 0; k < byteval.length; k++) {
			if (byteval[k] == byteval[byteval.length - k - 1]) {
				flag = true;
			} else {
				flag = false;
				k = byteval.length-1;
			}
		}

		return flag;
	}

	public static void main(String[] args) {
		new IfHuiWen2();
	}

}

展开阅读全文

没有更多推荐了,返回首页