I am trying to get the palindrome of a string and below is my code. The problem is, it is only executing the else condition
public class Palindrome {
public static void main(String[] args) {
String name = "aba";
StringBuilder sb = new StringBuilder();
sb.append(name);
sb = sb.reverse();
System.out.println(sb);
System.out.println(name);
if (sb.equals(name)) {
System.out.println(name + " is palindrome");
} else
System.out.println(name + " isn't palindrome");
}
}
Only the else
condition is executed.