You are creating an array of zero length (no slots to put anything in)
int array[]={/*nothing in here = array with no slots*/};
and then trying to assign values to array slots (which you don’t have, because there are none)
array[i] = number; //array[i] = element i in the array of length 0
You need to define a larger array to fit your needs
int array[] = new int[4]; //Create an array with 4 elements [0],[1],[2] and [3] each containing an int value