我写了一个检查回文的代码,但它显示所有输入为回文
class Solution {
public static void main(String[] args) {
String a = "shubham", reverse="";
StringBuilder input = new StringBuilder();
input.append(a);
System.out.println("Value of a:-"+a);
System.out.println("Value of b:-"+input.reverse().toString());
if(a.equals(input.reverse().toString())) {
System.out.println("Given input is palidrome");
}
else {
System.out.println("Given input is not palidrome");
}
}
上面的输出是:
a 的值:-shubham
b 的值:-mahbuhs
给定的输入是回文