String is palindrome

2 test cases are not working

@Amogh_Agarwal Note : I have used your submitted code for the assessment not the code that you have attached and there you haven’t take any input from the user your string str is always = “Madam” take input from user.After making the changes the code is below :

import java.util.*;
public class Main {
    public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
        String str =  sc.next();
	    System.out.println(isPalindrome(str));

	}
	public static boolean isPalindrome(String str)
	{
		String s="";
	    for(int i=str.length()-1;i>=0;i--){
	      s=s+str.charAt(i);
	      
	    }
	    if(s.equals(str))
	    return true;
	    else 
	    return false;
    }
}
1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.