public static boolean validPalindrome(int n) {
      final String numberToString = Integer.toString(n);
      final int length = numberToString.length();
      for (int i = 0; i <= (int) length / 2; i++) {
         if (!(numberToString.charAt(i) == numberToString.charAt((length - 1) - i))) {
             return false;
         }
      }
      return true;
   }