Thursday, 18 September 2014

Program for String Palindrome


import java.io.*;
class String_pallindrome
{
    public static void main(String s[]) throws Exception
    {
        String str1;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
        System.out.print("\nEnter String: ");
        str1 = br.readLine();
      
        StringBuffer sb = new StringBuffer(str1);
        StringBuffer str2 = sb.reverse();

        if((sb).equals(str2))
        {
            System.out.println("\nString is Pallindrome");
        }
        else
        {
            System.out.println("\nString is not Pallindrome");
        }
    }
}
Output

No comments:

Post a Comment