(int x)
| 1 | class Solution { |
| 2 | public boolean isPalindrome(int x) { |
| 3 | String _x = x+""; // integer convert string |
| 4 | String rev = ""; // store reverse |
| 5 | int i = 0; |
| 6 | for(i = _x.length()-1; i>=0; i--){ |
| 7 | rev += _x.charAt(i); |
| 8 | } |
| 9 | |
| 10 | if(_x.compareTo(rev) == 0){ |
| 11 | // correct |
| 12 | return true; |
| 13 | } |
| 14 | else{ |
| 15 | return false; |
| 16 | } |
| 17 | |
| 18 | } |
| 19 | } |