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 :
0 Comments