Palindrome integer

The problem

Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.

Breaking it down

public static void main(String[] args) {

    Scanner input = new Scanner(;
    System.out.print("Enter a integer: ");
    int num = input.nextInt();


    if (isPalindrome(num)) {
        System.out.println(num + " is a palindrome.");
    } else {
        System.out.println(num + " is NOT a palindrome.");


public static boolean isPalindrome(int number) {
    String numberAsString = String.valueOf(number);
    StringBuffer sb = new StringBuffer(numberAsString);
    String reversedNumber = sb.reverse().toString(); 

    return reversedNumber.equals(numberAsString);


Enter a integer: 12345
12345 is NOT a palindrome.