Java检查字符串是否是回文的方法 [英] Java way to check if a string is palindrome
本文介绍了Java检查字符串是否是回文的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查字符串是否是回文.我想学习一种使用最少的字符串操作来检查相同内容的简单方法
I want to check if a string is a palindrome or not. I would like to learn an easy method to check the same using least possible string manipulations
推荐答案
您可以尝试以下方法:
String variable = ""; #write a string name
StringBuffer rev = new StringBuffer(variable).reverse();
String strRev = rev.toString();
if(variable.equalsIgnoreCase(strRev)) # Check the condition
这篇关于Java检查字符串是否是回文的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文