Check String pallindrome

My code for checking if the string is a pallindrome or not is this, but I don’t know why it is running for infinite times.
Kindly, tell me why my code is wrong…

My Code:
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
String str=scn.nextLine();
System.out.println(ans(str,0,str.length()-1));

}
public static boolean ans(String str,int left, int right)
{

	if(left<right)
	{
		if(str.charAt(left)==str.charAt(right))
		{
			return ans(str,left++,right--);
		}
		else
		return false;
	}
	else
	return true;
}

}

change base Case

if(left>=right){
     return true
}

for minimum complexity
corrected code: