Reversing a number

Plz check error in my code.

import java.util.Scanner;

public class Reverse {

public static void main(String[] args) 
{
	 int n,ans=0;
		
		Scanner sc = new Scanner(System.in);
	   
	    n = sc.nextInt();
	   
	    int b[]=new int[1000];
	    
	    	int count = 0;
	        while(n != 0)
	        {
	            
	            n /= 10;
	            ++count;
	        }
	    
	    
	    
	    	for(int i=1;i<=count;i++)
		    {
	  
			    
	    	int rem=n%10;
	    	
	    	n=n/10;
	    	b[i]=rem;
	    	
	    	
	    }
	    
	    
	    for(int j=1;j<=count;j++)
	    {
	System.out.print(b[j]);
}

}
}

got my mistake. the value n was modified.