用java判断一个字符串是否为回文数,我的程序哪儿有问题?求解。。。
publicclassCountVowels{publicstaticvoidmain(String[]args){StringBuffers1=newStringBuf...
public class CountVowels {
public static void main (String[] args){
StringBuffer s1= new StringBuffer("non");
StringBuffer s2 = new StringBuffer(s1).reverse();
System.out.println("原来的数字:"+s1);
System.out.println("改变以后的:"+s2);
System.out.println(s2.toString().equals(s1));
if(s2.toString().equals(s1))
System.out.println("This Is A Palindrome");
else
System.out.println("This Is A Not Palindrome");
}
} 展开
public static void main (String[] args){
StringBuffer s1= new StringBuffer("non");
StringBuffer s2 = new StringBuffer(s1).reverse();
System.out.println("原来的数字:"+s1);
System.out.println("改变以后的:"+s2);
System.out.println(s2.toString().equals(s1));
if(s2.toString().equals(s1))
System.out.println("This Is A Palindrome");
else
System.out.println("This Is A Not Palindrome");
}
} 展开
展开全部
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer s1= new StringBuffer("non");
StringBuffer s2 = new StringBuffer(s1).reverse();
String str1 = new String(s1); //把得到的数据转换成String再比较
String str2 = new String(s2);
System.out.println("原来的数字:"+str1);
System.out.println("改变以后的:"+str2);
if(str1.equals(str2))
System.out.println("This Is A Palindrome");
else
System.out.println("This Is A Not Palindrome");
}
// TODO Auto-generated method stub
StringBuffer s1= new StringBuffer("non");
StringBuffer s2 = new StringBuffer(s1).reverse();
String str1 = new String(s1); //把得到的数据转换成String再比较
String str2 = new String(s2);
System.out.println("原来的数字:"+str1);
System.out.println("改变以后的:"+str2);
if(str1.equals(str2))
System.out.println("This Is A Palindrome");
else
System.out.println("This Is A Not Palindrome");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询