public static int[] toDigits(int number){
  ArrayList<Integer> digitsList=new ArrayList<Integer>();
  if (number == 0) {
    return new int[]{0};
  }
  while (number != 0) {
    digitsList.add(number % 10);
    number/=10;
  }
  int[] digits=new int[digitsList.size()];
  for (int i=digitsList.size() - 1; i >= 0; i--) {
    digits[i]=digitsList.get(digitsList.size() - i);
  }
  return digits;
}

public static int [ ] toDigits ( int number ) { ArrayList < Integer > digitsList = new ArrayList < Integer > ( ) ; if ( number == 0 ) { return new int [ ] { 0 } ; } while ( number != 0 ) { digitsList . add ( number % 10 ) ; number /= 10 ; } int [ ] digits = new int [ digitsList . size ( ) ] ; for ( int i = digitsList . size ( ) - 1 ; i >= 0 ; i -- ) { digits [ i ] = digitsList . get ( digitsList . size ( ) - i ) ; } return digits ; }
transforms an integer into a set of digits
