this code is not working properly, I tried this code with string "level" still it's executing the else statement
CODE -
import java.util.*;
public class rough {
static String reverse_checker(String a){
String reverse = "";
int b =a.length()-1;
while(b!=-1){
reverse+=a.charAt(b);
b--;
}
return reverse;
}
public static void main(String[] args) {
System.out.println("Enter the string to check wheter its a palindrome or not -: ");
Scanner sc = new Scanner(System.in);
String str = sc.next();
if(str==reverse_checker(str)){
System.out.printf("yes the String %s is a palindrome",str);
}else{
System.out.printf("NO the String %s is not a palindrome",str);
}
sc.close();
}
}