Regarding errors

can u plz explain the error occuring in this code ?
import java.util.*;

public class Main {

public boolean isPalindrome(String str){ 

String s;
String result;
for(int i=str.length()-1;i>0;i–){
s=""+str.charAt(i);
}
if(s.equals(str))
return true;
else
return false;

}

public static void main(String args[]) {
    // Your Code Her
    Main m = new Main();
    String str;
    Scanner sc = new Scanner(System.in);
    str = sc.nextLine();
  m.isPalindrome(str);
}

}

Hii ishant,in your function ispalindrome,you have to do s=s+str.charAt(i) as it will store the str string in s otherwise it is only storing the last character in s,and in the loop put condition i>=0 also to take the first character of the string,also print the answer you have returned.

this is your edited code for help
https://ide.codingblocks.com/s/56481

Hey Ishant, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.