String index out of range: -1 Please Help
Hello everyone. In my program i have a section that checks if a number is a palindrome (can be read forwards or backwards). This is my code:
if ((s.charAt(s.length() - x - 1)) == (s.charAt(s.length() - s.length() + x)))
and x is declared at 0. I get an error that says: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 along with some other stuff that I don't think is really that important. Can someone help me in figuring out this error? I don't know how the index could go below 0, when I'm never subtracting x (except for right there).
Thanks in advance.