Program to check palindrom of string

//Program to check palindrom of string
class Q4ipage154{
    public static void main(String ar[]){
        boolean b=pal("nitin");
        System.out.println(b);
    }
    static boolean pal(String s)
    {
        boolean p=true;
        int start=0,end=s.length()-1;
        while(start<end){
            if(!(s.charAt(start)==s.charAt(end))){
                p=false;
                break;
            }
            start++;
            end--;
        }
        return p;
    }
}

No comments:

Popular Posts