I'm not really sure why I am getting this error. The code is meant to test palindromes disregarding punctuation.
So here is my code:
char junk;
String temp = "";
for (int i = 0; i < txt.length(); i++)
{
junk = txt.charAt(i);
if (Character.isLetterOrDigit(txt.charAt(jumk)))
{
temp += junk;
}
}
txt = temp;
left = 0;
right = txt.length() -1;
while (txt.charAt(left) == txt.charAt(right) && right > left)
{
left++;
right--;
}
java.lang.StringIndexOutOfBoundException : String index out of range 0
at PalindromeTester.main(PalindromeTester.java:35)
and line 35 is as following:
while (txt.charAt(left) == txt.charAt(right) && right > left)