Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Palindrom
- {
- public static void main(String[] args)
- {
- Scanner in=new Scanner(System.in);
- String str=in.nextLine();
- int len=str.length() - 1;
- int i = 0;
- while (i < len) {
- if (str.charAt(i) != str.charAt(len)) {
- System.out.println("Not a palindrome");
- return;
- }
- i++;
- len--;
- }
- System.out.println("It is a palindrome");
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement