Advertisement
MCreeper12731

Untitled

Aug 3rd, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1. public static boolean isPalindrome(int num) {
  2.  
  3.     if (num < 0) return false;
  4.  
  5.     String stringNum = String.valueOf(num);
  6.  
  7.     for (int i = 0; i < stringNum.length() / 2 + 1; i++) {
  8.         if (stringNum.charAt(i) != stringNum.charAt(stringNum.length() - i - 1)) return false;
  9.     }
  10.  
  11.     return true;
  12.  
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement