How to check if a three digit number is a palindrome?
<p>I am creating a little trivial palindrome quiz in Java.  </p>

<p>I should at some point check if the user will enter more or less than a three digit number such as "1011" or "10" and display an error message such as "Wrong input." However, I can't check the length of a number with <code>int.length()</code> in Java, as I instead could do with a String (<code>String.length()</code>).</p>

<p>How could I solve this problem? </p>

<p>This is my code without the if-three-digit check</p>

<pre><code>import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        System.out.println("Please enter a three digit number number and I will check if it's a palindrome.");

        // create scanner and input number

        Scanner input = new Scanner(System.in);
        int number = input.nextInt();

        int digit1 = (int)(number / 100);
        int remaining = number % 100;
        int digit3 = (int)(remaining % 10);

        System.out.println(number + ((digit1 == digit3) ? " is a palindrome" : " is not a palindrome"));


    }
}
</code></pre>