Write a program in java to find that given number or string is palindrome or not




/* Write a program to find that given number or string is palindrome or not. */

import java.util.Scanner;

class Palindrome
     {
     public static void main(String  arg[])
       { String r="";
          Scanner  c = new Scanner(System.in);
           System.out.println("enter your string to check your string is palindrome or not ?");
           String s=c.nextLine();
            int l=s.length();
     int i;
for (i=l-1; i>=0;i-- )
{
   r=r+s.charAt(i);
                    }
              if (s.equals(r))
                   {
              System.out.println("your string is palindrome");
}
else

System.out.println("your string is not  palindrome");
        }
}
   

Comments

Popular posts from this blog

Write a java program to calculate gross salary & net salary taking the following data

WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants

Example of abstract class