/** * @author lautturi.com * Java example: Converts an integer to an array of digits in java */ import java.util.*; public class Lautturi { public static void main(String[] args){ int number = 110101; String temp = Integer.toString(number); int[] numbers = new int[temp.length()]; for (int i = 0; i < temp.length(); i++) { numbers[i] = temp.charAt(i) - '0'; } System.out.println(number); System.out.println(Arrays.toString(numbers)); } }Sou.www:ecrlautturi.com
output:
110101 [1, 1, 0, 1, 0, 1]