fork download
  1. import java.util.*;
  2.  
  3. class Ideone
  4. {
  5. static boolean isPalindrome( int N ){
  6. int temp = N;
  7. int rev = 0;
  8. while( N > 0){
  9. int digit = N%10;
  10. rev = rev*10+digit;
  11. N =N/10;
  12. }
  13. if(temp == rev){
  14. return true;
  15. }else{
  16. return false;
  17. }
  18. }
  19. public static void main (String[] args) throws java.lang.Exception
  20. {
  21. boolean result = isPalindrome( 125 );
  22. System.out.println( "125"+result );
  23.  
  24. boolean result2 = isPalindrome( 13431 );
  25. System.out.println( result2 );
  26. }
  27. }
  28.  
Success #stdin #stdout 0.15s 55596KB
stdin
Standard input is empty
stdout
125false
true