Index outof bound

why iam having this error indexoutofbound this is my code
public class Palendro {
public static boolean palen(String str)
{
int left=0;
int right=str.length()-1;
while(left<right)
{
if(str.charAt(left)!=str.charAt(right))
{
return false;
}
++left;
++right;
}
return true;
}
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
boolean st=palen(str);
System.out.println(st);
// TODO Auto-generated method stub

}

}

ok it is resolved now