Java Program To Reverse a number


public class Reverse{
    
    public static void main(String[] args){
int n=1234rev=0;

        while(n!=0){
            int rem=n%10;
            rev=rev*10+rem;
            n=n/10;
        }
        System.out.println(rev);
    
    }

} 

Ouput:4321

                         


Comments