Java Noob here, I wrote the following code to check if a given string is palindrome or not:
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String A=sc.next();
StringBuilder str = new StringBuilder(A);
StringBuilder original = new StringBuilder(A);
str.reverse();
if(str == original)
{
System.out.println("Yes");
}
else
System.out.println("No");
}
}
for input 'madam' it's saying NO? What is wrong with the code?