Aim:- Write a program to find that given number or string is
palindrome or not.
import
java.lang.*;
import
java.io.*;
import
java.util.*;
class
pra7
{
public static void main(String args[])
{
int len,i=0;
String str=new String();
Scanner s=new Scanner(System.in);
System.out.print("Enter your string:
");
str=s.nextLine();
StringBuffer s1= new StringBuffer(str);
s1.reverse();
if(str.compareTo(s1.toString())==0)
System.out.println("String is
Pelindrom");
else
System.out.println("String is not
Pelindrom");
}
}
Output:-
No comments:
Post a Comment