RGAlex

O9. PalindromeIntegers

Feb 8th, 2021
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package ExerciseMethoods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class O9PalindromeIntegers {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String command = scanner.nextLine();
  9.         while (!command.equals("END")) {
  10.             palindrome(command);
  11.             command = scanner.nextLine();
  12.         }
  13.     }
  14.  
  15.     public static void palindrome(String command) {
  16.         String reversed = new StringBuffer(command).reverse().toString();
  17.  
  18.         if (command.equals(reversed)) {
  19.             System.out.println("true");
  20.  
  21.         } else {
  22.             System.out.println("false");
  23.         }
  24.     }
  25. }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment