Java examples for java.lang:Math Number
Used to check if a number is a palindrome.
//package com.java2s; public class Main { /**//www . java2 s . c om * Used to check if a number is a palindrome. * A number is a palindrome if it is the same in reverse order as itself. example: 1230321. * This method takes as many shortcuts as it can to compute as quickly as possible. * @param operand the number to check * @return true if operand is a palindrome, false if it is not. */ public static boolean isPalindrome(long operand) { String op = new Long(operand).toString(); for (int i = 0; i < op.length() / 2; i++) { if (op.charAt(i) != op.charAt(op.length() - i - 1)) { return false; } } return true; } }