Advertisement
Vidinov

Palindrome

Feb 19th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Palindrom
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner in=new Scanner(System.in);
  8. String str=in.nextLine();
  9. int len=str.length() - 1;
  10. int i = 0;
  11. while (i < len) {
  12. if (str.charAt(i) != str.charAt(len)) {
  13. System.out.println("Not a palindrome");
  14. return;
  15. }
  16. i++;
  17. len--;
  18. }
  19. System.out.println("It is a palindrome");
  20. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement