
public class IterativePalin
{
    public static void main(String[] args)
    {
        String  s = "racecar";
        boolean ans;

        ans = isPalindrome(s);
    }

    public static boolean isPalindrome(String w)
    {
        boolean isPalindrome = true;
        int i, last;
      
        last = w.length() - 1;

        for ( i = 0; i < w.length()/2; i++ )
        {
            if ( w.charAt( i ) != w.charAt( last-i ) )
            {
                isPalindrome = false;
                break; // We can exit the loop now
            }
        } 
        
        return isPalindrome;
    }
}
