Unit 2
Prac 5
package pl;
import java.util.Scanner;
public class Pl {
public static void main(String[] args) {
String s,s2="";
Scanner in =new Scanner(System.in);
System.out.println("Enter String :");
s = in.nextLine();
for(int i = s.length()-1;i>=0;i--)
{
s2 = s2 + s.charAt(i);
}
if(s.equals(s2))
System.out.println("palindrome");
else
System.out.println("not palindrome");
}
}
output:
Enter String :
gajjar
not palindrome
Enter String :
12321
palindrome
No comments:
Post a Comment