e.g. for int n = 1234
I could create a string (s.valueOf(n))
, then I would define the array like this:
int[] array = new int[s.length()]; //this allocates memory for an array with 4 elements
Is there any other way to do this without using a string and only integers?