Java Program to Find That Given Number is Palindrome or Not


Aim :- Write a java program to find that given number is palindrome or not.

Java Program :


import java.util.*; 
class palin
{
     public static void main(String args[])
     {
          String ori, rev = "";
          Scanner sc = new Scanner(System.in);
          System.out.print("Enter String : ");
          ori= sc.nextLine();
          int length = ori.length();
          for (int i=length-1;i>=0;i--)
          {
               rev= rev+ ori.charAt(i);
          }
          if (ori.equals(rev)) {
               System.out.println("The Given String is Palindrome.");
          } else {
               System.out.println("The Given String is Not Palindrome.");  
          }
     } 
}

Output :



Post a Comment

0 Comments