Reverse number | palindrome number in Java

Reverse Number in Java

class ReverseNumber {

    public static void main(String[] args) {     

      int n = 123;

    int originalN = n;

    int revN = 0;

       while(n>0){

           int ld = n%10;

           System.out.print(ld);

        revN= revN*10+ld;

           n /= 10;

}     

if(originalN == revN){
  System.out.print("yess");

    }

else{

 System.out.print("Noo");}

}

}


Output: 321 Noo


Palindrome Number in Java



No comments: