How to Access 1 digit at at time of an int in Java

How to access each digit in an int in Java

int n ; // some integer 

while ( n > 0){
		int digit = n % 10 ; //ones place digit
		print(digit) ;
		n = n / 10 ; // now the ones place by int division
		}