Thursday, 12 March 2015

Palindrome Program: (Core JAVA)

public class Palindrome
{

       public static void main(String[] args)
       {            
System.out.println("Enter Word");
              Scanner src=new Scanner(System.in);
              String original=src.next();
              String reverse="";
              int length=original.length();
              for(int i=length-1;i>=0;i--)
              {
                     reverse=reverse+original.charAt(i);
              }
              if(reverse.equals(original))
              {
                     System.out.println("Pallandrome");
              }
              else
              {
                     System.out.println("Not pallandrome");
              }
}

}

No comments:

Post a Comment