Basically, you can try with the following code:
public static boolean isPalindrome(int integer) {
int palindrome = integer;
int reverse = 0;
// Compute the reverse
while (palindrome != 0) {
int remainder = palindrome % 10;
reverse = reverse * 10 + remainder;
palindrome = palindrome / 10;
}
// The integer is palindrome if integer and reverse are equal
return integer == reverse; // Improved by Peter Lawrey
}
I hope this will help.
Want to become a Java expert? Join Java Certification now!!
Want to know more about Java? Watch this video on Java Training | Java Course for Beginners: