Is there a better way to write this in Java?
<pre><code>public class Palindrome
{
   public static void main ( String [] args )
   {
       Scanner scan = new Scanner ( System.in ) ; // new object named "scan"
       System.out.println ( "\nPlease enter a number: "  ) ;
       int num = scan.nextInt () ; //store number into num

       if ( ( (num /1000)==(num%10) ) 
            &amp;&amp; (    ( (num/10) %10 ) == ( (num/100)%10  )   ) ) 
           // num = 'abcd' : if (a=d) and (b=c) number is a palindrome.
            System.out.println ( "\nIs a Palindrome !"  ) ;
      else 
            System.out.println ( "\nNot a Palindrome !"  ) ;
   } //end of method main
} //end of class Palindrome
</code></pre>

<ol>
<li>Is there a way to optimize this code?
I need to deal only with a 4 digits number ONLY !</li>
<li>How do I add a check that the number is a truly a positive number and a 4 digits number ?</li>
</ol>
