Java examples for java.lang:Math Number
Gets if a number is a palindrome
//package com.java2s; public class Main { /**//from ww w . j a v a 2s . co m * Gets if a number is a palindrome * * @param num The number to test * @return If the number is a palindrome */ public static boolean isPalindrome(long num) { String numString = String.valueOf(num); for (int i = 0; i < numString.length() / 2; i++) { if (numString.charAt(i) != numString.charAt(numString.length() - 1 - i)) return false; } return true; } }