I was trying to reverse a String and then compare it with first string. When I print my variables A and C for the value "madam" gets the same value, but when I try to do a boolean evaluation, it returns false. I don't know why.
public class Random_practise {
public static void main (String[] args){
String A ="madam";
int i = A.length() - 1;
char B[] = new char[A.length()];
for (int k = 0; k<A.length(); k++ ){
B[k] = A.charAt(i);
i--;
}
String C = valueOf(B);
if (A == C){
System.out.println("Yes");
}
else{
System.out.println("No");
}
}
}