判断回文算法

判断回文算法代码简化至7行
问题:一串字符正序和倒序都相同为回文,请编写程序实现

源代码:

public class Palindrome {
	public static void main(String args[]) {
		String s1="apyeypa";
		String s2=new StringBuffer(s1).reverse().toString();
		System.out.println(s1.equals(s2)==true?"YES":"NO");
	}
}

运行结果:
在这里插入图片描述

发布了53 篇原创文章 · 获赞 1 · 访问量 2796

猜你喜欢

转载自blog.csdn.net/weixin_43873198/article/details/103548281